Indicator creation

abc

New Member
#1
I am trying to create an indicator. According my model it should be structured as following
10 IF (var1/sumvar) >= 90% of sumvar
9 if (var1+var2+var3/sumvar) >=90% of sumvar
8 if (var1/sumvar) >= 80% of sumvar
7 if (var1+var2+var3/sumvar)> =80% of sumvar
and so on...

I am running the following commands on stata

gen newvar = 0

. replace newvar = 10 if (var1 / sumvar) *100>=90
replace newvar = 9 if (var1+var2+var3/sumvar) *100>=90
replace newvar = 8 if (var1 / sumvar) *100 >= 80 < 90
replace newvar = 7 if (var1+var2+var3 / sumvar) *100 >= 80 < 90

and so on...


By now you should have understand the pattern.Any time the additional variable(s) enter the model (in other words there are observation for at least one of var2 and/or var3 the indicator takes other values. Here comes the problem. The indicator looks fine when I include only the var1 but creates problems when all three variables are included.
The indicator changes its values to those when all three variables are included even in cases where there are no observation for the other two variables(var2 and var3) and it shouldn't be there .This is a significant error in my theory. I know from my data and from common knowledge that those values are wrong.

My data are all right and there is not such kind of problem.The problem is that I probably need to insert and an if and only if condition in stata. If observation for var1 exist only then assign that value as above .If var1 and at least one of var2 and/or var3 exist then assign to the indicator that value as above.

I would appreciate any suggestion on how to proceed

thanks
abc