Statalist


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

st: AW: Summing across variables


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Summing across variables
Date   Tue, 6 Oct 2009 22:34:09 +0200

<> 

If these variables to be summed are neatly arranged one after another, the
best thing it to use -egen, rowtotal()- with the "hyphen" syntax like
"this-that" - which gives you all the variables between those two. See -help
varlist- and -help order-. 

If you wanted the sum of all variables, you could use the abbreviation
-_all- as an argument to -rowtotal()-.



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von John Pfaff
Gesendet: Dienstag, 6. Oktober 2009 21:52
An: [email protected]
Betreff: st: Summing across variables

Hello,

I am trying to create a fast way to generate a new variable that is the sum
of a lot of variables. Obviously varnew = var1 + var2 + var3 works, but I
have to think there is a better way, since I may have up to 50 or 100
variables across which I want to sum. Handtyping that out seems inefficient,
and I'd like the flexibility of being able to vary the number of variables
I'm summing across easily. Thanks so much for any suggestions!

All the best,

John

Associate Professor of Law
Fordham University School of Law
140 West 62nd Street
New York, New York 10023
Phone:  (212) 636-7661
Fax:       (212) 636-6899
E-mail:    [email protected]

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