Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: -reshape-, or -by-?


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: -reshape-, or -by-?
Date   Wed, 9 Apr 2003 11:46:42 -0400

> -----Original Message-----
> From: Richard Sherman [mailto:sherman@maxwell.syr.edu] 
> Sent: Wednesday, April 09, 2003 11:41 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: RE: -reshape-, or -by-?
> 
> 
> Nick,
> 
> Wow.  A one-line command that executes in about one second.  
> Very nice.
> Thanks!
> 
> How about:
> 
> 	foreach v of varlist var1 var2 ... {
> 	  egen `v'_sum = sum(`v'), by(year)
> 	}
> 

Be careful, by the way, about missing data or countries -- the sum of a
variable might not be comparable across years if there is missing data
for some countries.  If that's a concern, perhaps the mean (rather than
sum) would be a better measure.

Nick Winter


*
*   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