Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: st: addition of variables in Stata 11


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: addition of variables in Stata 11
Date   Sun, 25 Oct 2009 20:11:55 +0100

<> 



Anything in official -egen- that expects to be fed a -varlist- does not allow -by-. Intuitively: You select the _columns_ that you want these functions to process. Functions that expect anything other than a -varlist- do sometimes allow the -by- prefix: You select chunks of _rows_ that should be treated as units for the purposes of the calculation...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Ekaterina Hertog
Gesendet: Sonntag, 25. Oktober 2009 20:07
An: [email protected]
Betreff: Re: st: addition of variables in Stata 11

Dear Nick, Martin and John,
Thank you very much for the advice! Nick's and Martin's clarifications 
on the impossibility of using the -by option is taken.
Sincerely yours,
Ekaterina

Nick Cox wrote:
> Please note: 
>
> 1. This is the same function as -egen, rowtotal()- named in my earlier post. -rsum()- was renamed -rowtotal()- in Stata 9. 
>
> 2. However, -by()- is irrelevant to row-wise operations and is in any case not supported (i.e. illegal) with this function. 
>
> Nick 
> [email protected] 
>
> John Ataguba
>
> I suppose these are variables created in rows.  You can try:
>
> egen newvar = rsum(citotal*)
>
> Note that you can also combine this with the by option if you want to restrict to a certain group or so...
>
> Ekaterina Hertog <[email protected]>
>
> I have a set of variables which denote population by age group in a
> location a given individual lives in my dataset and I want to add them
> up to total population in a location where each individual lives.
> The names of the variables I have look as follows:
> citotal1519 (meaning total population of 15 to 19 year olds in the city)
> citotal2024 (meaning total population of 20 to 24 year olds in the city)
> citotal2529 (meaning total population of 25 to 29 year olds in the city)
> …
> citotal7074 (meaning total population of 70 to 74 year olds in the city)
>
> I was wondering if it might be possible to somehow ask Stata to add all
> the variables which start with citotal?
>
> *
> *   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/
>   


-- 
Ekaterina Hertog (née Korobtseva)
Career Development Fellow
Department of Sociology and Nissan Institute of Japanese Studies
University of Oxford

27 Winchester Road
Oxford
OX2 6NA
United Kingdom


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



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