Hi all,
First time posting - very grateful for this well-resourced community that has helped me thus far.
Using Stata13.0. Please see below for excerpt of dataset I am using.
treatmentsource1 treatmentsource1_exp treatmentsource2 treatmentsource2_exp treatmentsource3 treatmentsource3_exp formal_public
1 700 2 1000 3 400
1 200 3 500 8
1 200 3 800 8
1 200 3 500
1 200 3 500
1 200 3 300
1 300 3 500
I am trying to create a dummy variable (formal_public) that evaluates to 1 when either treatmentsource1, treatmentsource2, or treatmentsource3 are 1 and their relative expenditure value (treatmentsource1_exp, treatmentsource2_exp2, treatmentsource3_exp3) is larger than the other two expenditure values.
My understanding of this would be something like:
replace formal_public=1 if (treatmentsource1==1 & treatmentsource1_exp>treatmentsource2_exp & treatmentsource1_exp>treatmentsource3_exp)|(treatm entsource2==1 & treatmentsource2_exp>treatmentsource1_exp & treatmentsource2_exp>treatmentsource3_exp)|(treatm entsource3==1 & treatmentsource3_exp>treatmentsource1_exp & treatmentsource3_exp>treatmentsource2_exp)
However, when I ran this, it only made one real change, when there are numerous instances when the category 1 treatment source has the largest relative expenditure compared to other treatment sources. I am wondering if this could be due to the missing values (i.e., will Stata evaluate an expenditure to 1 if it also compares this expenditure to missing values, which is what I would like it to do)?
Further, if possible, I would like to distinguish between individuals who only list one treatment source and its expenditure (as this should to evaluate to 1, as the primary source of treatment) and individuals who list multiple treatment sources but did not also list the associated expenditure (this should evaluate to missing).
Hope this explanation provides enough detail.
Many thanks,
Harry
0 Response to Problem combining multiple IF qualifiers which reference value of other variable entries
Post a Comment