Statalist


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

RE: st: AW: AW: sum of many variables


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: AW: AW: sum of many variables
Date   Tue, 27 Oct 2009 14:00:09 -0000

As the order of variables is quite immaterial to their sum, another
possibility is to use a wildcard such as -x*-. As always you need to
check that it picks up exactly what you want and no more. 

Nick 
n.j.cox@durham.ac.uk 

Andrea Rispoli

Thank you very much!

On Mon, Oct 26, 2009 at 7:54 PM, Martin Weiss <martin.weiss1@gmx.de> 
>
> 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-...
>
Martin Weiss

> *************
> egen x=rowtotal(x1-xn)
> *************

Andrea Rispoli

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

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index