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

st: AW: Summing across variables

From   "Martin Weiss" <>
To   <>
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()-.


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


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,


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

*   For searches and help try:

*   For searches and help try:

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