<>
" As always you need to check that it picks up exactly what you want and no
more."
Andrea may like -unab- for the purpose of checking for the right stuff
inside her -varlist-:
****
clear*
set obs 1
gen myvar1=1
gen myvar2=1
gen myvarr=4
gen mvar=9
unab vars: myvar*
di "`vars'"
****
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Nick Cox
Gesendet: Dienstag, 27. Oktober 2009 15:00
An: [email protected]
Betreff: RE: st: AW: AW: sum of many variables
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
[email protected]
Andrea Rispoli
Thank you very much!
On Mon, Oct 26, 2009 at 7:54 PM, Martin Weiss <[email protected]>
>
> 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/
*
* 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/