Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72793

Summing across numerous variables if observation equals a specific value

$
0
0
Hey!

I have 9 different variables that I want to sum up. But I only want to sum the 1's.
I tried: egen new_varname = rowtotal(var1-var9) if var1-var9==1

But that is giving me missing values since not all observations==1.

If there e.g. three 1's in the var range, the number I should get is 3.

Can someone help?

Thanks so much.

Claudia

Viewing all articles
Browse latest Browse all 72793

Trending Articles