Statalist The Stata Listserver


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

Re: st: sum command


From   Richard Williams <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: sum command
Date   Mon, 23 Jan 2006 22:03:51 -0500

At 09:52 PM 1/23/2006, Baoyan Cheng wrote:
Hi, there,

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)


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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