Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Martijn S <martstouthart@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: command forvalues with multiple if expressions |
Date | Tue, 3 May 2011 11:00:58 +0200 |
Problem solved. Thanks a lot! 2011/5/3 Maarten buis <maartenbuis@yahoo.co.uk>: > > --- Martijn Stouthart >> I have a problem getting the forvalues command working the way I want. >> I have the following problem. I have the following variables: >> cftassets3ysd, industrycode and year. Where industrycode has a range >> from 1-100 and year a range of 1999 to 2009. >> >> Now I want the following. I want for each industrycode in each year >> the mean of cftassets3ysd belonging to that industrycode in that year. >> Preferably I want all values be generated in one column. I also have >> to note that some observations of cftassets3ysd have missing values, >> so as a result I want those to be treated in the right way, thus as >> missing values. >> >> Unfortuneatly I cannot get the forvalues loop working. > > This is not a -forvalues- problem. Just type: > bys industrycode year : egen industrysigma = mean(cftassets3ysd) > > Hope this helps, > Maarten > > -------------------------- > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > > http://www.maartenbuis.nl > -------------------------- > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/