Lena,
You need -egen-.
. egen gh_raw = rowtotal(gh1 gh2 gh3 gh4 gh5)
. gen gh_avg = gh_raw/5
Friedrich
On Mon, Mar 16, 2009 at 6:05 PM, Lena Cuisina <[email protected]> wrote:
>
> I have a very basic question. I’m adding up responses to 5 questions. Some of the questions have missing data. This is what I don’t want to do, because I don't want to lose the 23 observations:
>
> . gen gh_raw = gh1 + gh2 + gh3 + gh4 + gh5
> (23 missing values generated)
>
> . gen gh_avg = gh_raw/5
> (23 missing values generated)
>
> I want to use whatever data I’ve got from the other questions in calculating the sum -- ie, I’d like to great the missing as zero, not missing. So I tried the sum function:
>
> gen gh_raw1 = sum(gh1+gh2+gh3+gh4+gh5)
>
> gen gh_avg1 = gh_raw1/5
>
> All 5 questions have the same 5-category ordinal response scale that’s coded 0, 25, 50, 75, 100. So the average of the 5 responses are within the 0 to 100 range. Unfortunately, the command I've written with the sum function gives me a set of average scores with a maximum of 18,800. It’s crazy.
>
> I have no idea what I’m doing wrong, because I’m pretty new to Stata. Sorry for such a basic question.
>
> Lena
*
* 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/