Dear Stata users,
I want to generate a new variable which equals row sum of the variables in varlist, and to each variable I must assign a weight. Now I use the following code:
If there's a missing value in any variable, the new variable will be set to missing also. The egen rowtotal function has an advantage that if there is any missing values it will then treat missing values as 0. However, the egen rowtotal function doesn't allow us to assign weight to each variable in varlist. Is there any command to combine the rowtotal caculation and weight assighment? Thank you very much.
I want to generate a new variable which equals row sum of the variables in varlist, and to each variable I must assign a weight. Now I use the following code:
Code:
generate newvar = var1*wgt1 + var2*wgt2 + var3*wgt3 + …
Comment