I want to create a new variable in Stata, that is a function of let's say 3 different variables, A, B and C, like so:
gen new_var = ((A)/3) + ((B)/2) + ((C)/4)
All observations have missing values for one or two of the variables, but that is not relevant to what I am trying to do. When I run this command, all it generates are missing values, because no observation has values for all 3 of the variables. I want STATA to complete the function and treat missing variables as 0 in the function. Is that possible with a simple command, without generating new dummy variables?
Many thanks.
gen new_var = ((A)/3) + ((B)/2) + ((C)/4)
All observations have missing values for one or two of the variables, but that is not relevant to what I am trying to do. When I run this command, all it generates are missing values, because no observation has values for all 3 of the variables. I want STATA to complete the function and treat missing variables as 0 in the function. Is that possible with a simple command, without generating new dummy variables?
Many thanks.
Comment