Statalist The Stata Listserver


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

RE: st: foreach program


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: foreach program
Date   Fri, 8 Sep 2006 16:46:28 +0100

OK. Just straining to see from here what
might be problematic. 

Nick 
[email protected] 

Scott Cunningham
 
> On Sep 8, 2006, at 11:30 AM, Nick Cox wrote:
> 
> > Also, you are not consistent about what -age-s
> > you are working with.
> >
> 
> Nick,
> 
> You're referring to the last three lines of this original code, right?
> 
> foreach i of num 1/`r(max)' {
> 		gen i=perwt if age>=15 & age<=19 & group==`i' & 
> gqtyped==200
> 		gen p=perwt if age>=15 & age<=19 & group==`i'
> 		egen itot=sum(i)
> 		egen ptot=sum(p)
> 		replace ir_level=itot if age==15 & group==`i'
> 		replace pop_level=ptot if age==15 & group==`i'		
> 		replace ir=itot/ptot if age==15 & group==`i'
> 		drop i p itot ptot
> 		}
> 
> I only record the "ir," "pop_level," and "ir_level" values for  
> age==15 because I am merging these data with a data set on health  
> outcomes, where health outcomes are delineated by an age variable  
> that is in groupings of five year increments.  So, there is a value  
> of "15" for the "age" variable in this separate dataset.  I record  
> only values for the age==15 to save space, since I will later be  
> dropping all observations not equal to 15, 20, 25, and so on.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index