Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: New to Looping?


From   "Ms. Marilyn Ibarra" <ibarra@uga.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: New to Looping?
Date   Fri, 15 Sep 2006 15:12:07 -0400 (EDT)

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index