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
melogit with crossed (non nested!) factors does not workDear all, thanks in advance. I have an issue that freaks me out. I wonder if I'm wrong to set up th…
Using local macros in tslineHi, I am using Stata 16 and would need help in macros. Below is my dataset: Code: * Example gener…
Ratio of male to female in a datasetHello. It's probably an easy question but I searched a lot and found nothing. I have a data set an…
Finding last day of the monthHello, I have the following code: Code: generate dayofmonth = day(date) rename (THENATIVE-ZWAHLENM…
Panel data and OLS assumptionsHi! Few days ago, there was an online webinar in my country in which the lecturers stated that many …
Subscribe to:
Post Comments (Atom)
0 Response to Problem combining multiple IF qualifiers which reference value of other variable entries
Post a Comment