Hi everyone,
I have a data set with different companies from 2002 till 2018, with the percentage of unionization per year per firm. I tried to create two dummy variables for the unionization variable(union_mem_t1). One, which is 1 when the observation is in the highest quantile of the unionization variable and one that equals 1, when it is in the lowest quantile.
I used the code below, which seems to work but the observations allocated to the yearly high and low quantile change every time I rund the do file.
bysort year (union_mem_t1): gen byte union_mem_dummy_quanhigh_t1 = _n > (0.75 * _N)
bysort year (union_mem_t1): gen byte union_mem_dummy_quanlow_t1 = _n < (0.25 * _N)
I then tried
xtile union_mem_dummy_quan_t1 = union_mem_t1, n(4)
gen union_mem_dummy_quanhigh_t1= union_mem_dummy_quan_t1
replace union_mem_dummy_quanhigh_t1 =0 if union_mem_dummy_quanhigh_t1!=4
replace union_mem_dummy_quanhigh_t1 =1 if union_mem_dummy_quanhigh_t1==4
gen union_mem_dummy_quanlow_t1= union_mem_dummy_quan_t1
replace union_mem_dummy_quanlow_t1 =0 if union_mem_dummy_quanlow_t1!=1
replace union_mem_dummy_quanlow_t1 =1 if union_mem_dummy_quanlow_t1==1
to see if I have the same problem when I am creating the dummies over all years and here the allocation is constantly the same.
Could someone please kindly help me to understand this? I would be really grateful.
Thank you in advance
Related Posts with Problem with creating yearly Quantile dummies
IV regression and 2SLSIs okay to use one instrumental variable for 2SLS multiple regression? …
svy: logit command stuck on "(running logit on estimation sample)"Hi, I'm trying to run a set of svy: logit commands, but for some reason, including certain variables…
how can I program this log-likelyhood function?Could any one kindly help me program this log-likelyhood funtion in Stata? Sorry inadvance, for the …
What is the problem when using the grqreg code?hi, guys! I'm wondering a question that when I use grreq to plot the coefficient of quantile regress…
how to fix scales on stataHi, I am working on a project and I have 4 variables that go from 0-100, and I am trying to combine …
Subscribe to:
Post Comments (Atom)
0 Response to Problem with creating yearly Quantile dummies
Post a Comment