Hi community
I have posted here before without getting any help and I am posting again to seek your kind help on the following :
- I need to create an indicator variable by sorting firms randomly and assigning the first X # of firms to treatment based on how many actual X # firms are treated that year.
so suppose the number of treated firms in 2005 = 50, I would like to randomly assign the first 50 firms in 2005 as treated, and the same goes for all the years. how can I code this in Stata, please?
Here are descriptions of my variables below: magnitude is my DV, treatedxmadnate is my IV, policey_in _effect refers to a dummy = one once the country mandates a policy during a given year and remains one for the future years, and zero otherwise. treated x mandate refers to firms effected by the mandate. Policey1year refers to the first year a country mandates the policy.
input str44 Country int Year float(firm_id magnitude treatedxmandate policy_in_effect) int Policy1Year
"United States" 2019 3062 1.6 0 0 .
"Brazil" 2011 216 .74 0 0 .
"New Zealand" 2013 2420 1.11 0 0 .
"Hong Kong" 2019 137 .6 1 1 2014
"South Korea" 2013 1866 .63 1 1 2012
"Japan" 2019 1766 .590 1 1 2005
"United States" 2012 2965 .95 0 0 .
"Japan" 2007 1344 .83 1 1 2005
"United States" 2006 2832 .93 0 0 .
"Sweden" 2007 2631 .429 1 1 2005
"South Korea" 2017 1828 .32 1 1 2012
"Switzerland" 2016 319 .48 0 0 .
"Sweden" 2013 2572 .47 1 1 2005
I appreciate your help.
I have posted here before without getting any help and I am posting again to seek your kind help on the following :
- I need to create an indicator variable by sorting firms randomly and assigning the first X # of firms to treatment based on how many actual X # firms are treated that year.
so suppose the number of treated firms in 2005 = 50, I would like to randomly assign the first 50 firms in 2005 as treated, and the same goes for all the years. how can I code this in Stata, please?
Here are descriptions of my variables below: magnitude is my DV, treatedxmadnate is my IV, policey_in _effect refers to a dummy = one once the country mandates a policy during a given year and remains one for the future years, and zero otherwise. treated x mandate refers to firms effected by the mandate. Policey1year refers to the first year a country mandates the policy.
input str44 Country int Year float(firm_id magnitude treatedxmandate policy_in_effect) int Policy1Year
"United States" 2019 3062 1.6 0 0 .
"Brazil" 2011 216 .74 0 0 .
"New Zealand" 2013 2420 1.11 0 0 .
"Hong Kong" 2019 137 .6 1 1 2014
"South Korea" 2013 1866 .63 1 1 2012
"Japan" 2019 1766 .590 1 1 2005
"United States" 2012 2965 .95 0 0 .
"Japan" 2007 1344 .83 1 1 2005
"United States" 2006 2832 .93 0 0 .
"Sweden" 2007 2631 .429 1 1 2005
"South Korea" 2017 1828 .32 1 1 2012
"Switzerland" 2016 319 .48 0 0 .
"Sweden" 2013 2572 .47 1 1 2005
I appreciate your help.
Comment