Statalist


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

Re: st: Summing across variables


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: Summing across variables
Date   Tue, 06 Oct 2009 16:07:54 -0400

I think there are two issues here:

1. the command -- if you use your command and at least one of the
variables is missing you will have missing as the result; this is
probably not what you want so use the rowtotal function of -egen-

2. see -help varlist- for ways to shorten what you need to type for the
list of variables

Rich

John Pfaff wrote:
> 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/



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