Re: st: New to Looping?

Sorry, I hit tab and it sent the email without me finishing:
Ok, so I wanted to create the following variable (r_va02) using (clc_va02) for Year 2002. However, I need to create the following variables r_va98 through r_va04 in the same fashion as I created r_va02 below. Is there a way that I can set this up so I do not have to repeat the code below for each new variable.
Thanks,
Marilyn.
gen r_va02 = clc_va02/ppp_food if nace_ind=="da15";
replace r_va02 = clc_va02/ppp_tobacco if nace_ind=="da16";
replace r_va02 = clc_va02/ppp_clothing if nace_ind=="db17" | nace_ind=="db18" | nace_ind=="dc19";
replace r_va02 = clc_va02/ppp_gdp if nace_ind=="dd20" | nace_ind=="de21" | nace_ind=="de22" | nace_ind=="df23" | nace_ind=="dg24" | nace_ind=="dh25" | nace_ind=="di26"| nace_ind=="dj27" | nace_ind=="dj28" | nace_ind=="dm34" | nace_ind=="dm35" | nace_ind=="dn36";
replace r_va02 = clc_va02/ppp_mach_eqp if nace_ind=="dk29" | nace_ind=="dl30" | nace_ind=="dl31" | nace_ind=="dl32" | nace_ind=="dl33";
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/