Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: sum command


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: sum command
Date   Tue, 24 Jan 2006 12:12:57 -0000

The commas are the issue. Spaces or not is not 
an issue. I recommend spaces around = for
readability, but that's partly a matter of taste. 

Nick 
[email protected] 

Richard Williams
 
> At 09:52 PM 1/23/2006, Baoyan Cheng wrote:

> >Does anyone know the correct command for doing sum in STATA?
> >
> >I need to add together seven variables to form one measure called 
> >"anxiety." I could simply add all the seven variables together, but 
> >STATA would drop any observation that misses one of the seven 
> >variables. I want STATA to treat missing values as 0 if at least one 
> >of the seven variables is not missing, and that's what the command 
> >"sum" is supposed to do (I thought).
> >
> >I tried the following commands, but none of them worked:
> >
> >1)egen anxi_sum=rsum (careopin, nervoppsex,nervsocial, nervpublic, 
> >worrlaug, worrdrop, worrburd)
> >2)egen anxi_sum=sum (careopin, nervoppsex,nervsocial, nervpublic, 
> >worrlaug, worrdrop, worrburd)
> >3)gen anxi_sum=sum (careopin, nervoppsex,nervsocial, nervpublic, 
> >worrlaug, worrdrop, worrburd)
> >
> >The first was said to be "invalid syntax"; the second one "variables 
> >in the parentheses are
> >invalid names"; and the third one "sum not found."
> 
> There may be other problems, but at a minimum get rid of the spaces 
> between the function and the parentheses and also replace the commas 
> with spaces, e.g.
> 
> egen anxi_sum=rsum(careopin nervoppsex nervsocial nervpublic worrlaug 
> worrdrop worrburd)

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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