Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: RE: R: the egen command |
Date | Fri, 22 Nov 2013 17:09:10 +0000 |
<> Note that a wildcard will probably suffice here, e.g. egen ENG2006_11 = rowsum(EN_WAL_births_2006-EN_WAL_births_2011) Details may vary depend on the order of your variables and what else there is. Nick njcoxstata@gmail.com On 22 November 2013 16:46, PAPANIKOLAOU P. > Thank you very much for your creative feedback. It is most kind of you. Carlo Lazzaro > if you are interested in the row sum of your variables, your code should be: > > egen ENG2006_11= rowtotal(EN_WAL_births_2006, EN_WAL_births_2011, EN_WAL_births_2010, EN_WAL_births_2009, EN_WAL_births_2008, > EN_WAL_births_2007) > > For further details on this handy command - help egen - is the right place to start. [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di PAPANIKOLAOU P. > I tried to use the commands: egen, sum on each occasion, but with no success. > How best could I get the sum of the variables i.e., X1+X2+...+Xn. > > . egen ENG2006_11= sum(EN_WAL_births_2006, EN_WAL_births_2011, EN_WAL_births_2010, EN_WAL_births_2009, EN_WAL_births_2008, > EN_WAL_births_2007) -- r(198); > > . gen ENG2006_11= sum(EN_WAL_births_2006 EN_WAL_births_2011 > EN_WAL_births_2010 EN_WAL_births_2009 EN_WAL_births_2008 EN_WAL_births_2007) > -- r(198); * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/