Statalist


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

Re: st: AW: AW: sum of many variables


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: AW: AW: sum of many variables
Date   Mon, 26 Oct 2009 15:20:12 -0400

Martin Weiss <[email protected]> :
Should be -order- order rather than -sort- order, right?
One can also accumulate a varlist as a local v and then
  egen x=rowtotal(`v')
(for example using the -unab- command).

On Mon, Oct 26, 2009 at 2:54 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
>
> Note, however, that there is a hazard involved when specifying a -varlist-
> that encompasses all variables between "x1" and "xn" via the dash notation:
> The number of variables between them changes with the -sort- order, as seen
> after -describe- (see [U], page 101, example 14). So next time you run this
> code, the result could be different. Issuing an explicit -sort- or -order-
> could save you trouble.
>
> Also note that the -sum()- function would give you a running sum, and
> accepts only a -varname-, not a -varlist-...
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Martin Weiss
> Gesendet: Montag, 26. Oktober 2009 19:45
> An: [email protected]
> Betreff: st: AW: sum of many variables
>
>
> <>
>
>
>
> *************
> egen x=rowtotal(x1-xn)
> *************
>
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Andrea Rispoli
> Gesendet: Montag, 26. Oktober 2009 19:46
> An: [email protected]
> Betreff: st: sum of many variables
>
> Dear Statalisters,
>
> I would like to use the sum command, i.e.
>
> egen x= sum (x1, x2...xn)
>
> however since my n is a large number I would like to indicate that I
> want the sum from x1 to xn without specifying all variables.
>
> Do you have any suggestions?
>
> Thank you very much in advance
>
> AR

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