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
Related Posts with Problem combining multiple IF qualifiers which reference value of other variable entries
-margins- after -xtlogit,fe-Dear Statalist This is a question about interpreting the results from a panel data fixed-effects lo…
Looping over correlation functionI am trying to produce a dataset that includes the autocorrelations of a variable (ret) across group…
Loop over multiple arrays via foreachHello together! trying now since a few hours to fix my problem - I am not able to come up with an a…
Logit Regression Model / Plotting InteractionsHi everyone, I am working at my final paper and need some guidance. I want to look at the party id…
ICD 10 to ICD-9 mapping using GEMsHi stata users, anybody has any experience in using GEMs files to map backwards from icd10 to ICD10 …
Subscribe to:
Post Comments (Atom)
0 Response to Problem combining multiple IF qualifiers which reference value of other variable entries
Post a Comment