Hello!
I am completely new to Stata, but after some trial and error I am almost done with my project.
However, for my last test I need to split a variable and assign a dummy variable for either large or small values.
This is my current command
set more off
gen cd=.
local j=2002
while `j'<=2012{
egen rank`j'=rank(data2025) if closdate_year==`j'
egen perc`j'=pctile(rank`j'), p(50)
quietly replace cd=1 if rank`j'>=perc`j' & closdate_year==`j'
quietly replace cd=0 if rank`j'<perc`j' & closdate_year==`j'
drop rank`j' perc`j'
local j=`j'+1
}
sort id closdate_year
gen small=.
quietly by id: replace small = 1 if cd==0
replace small=0 if cd==1
However, I wish to split this based on values, not on percent. I am basicly giving splitting my data of banks into small and large based on the value of their total assets.
Thanks in advance!
Einar.
I am completely new to Stata, but after some trial and error I am almost done with my project.
However, for my last test I need to split a variable and assign a dummy variable for either large or small values.
This is my current command
set more off
gen cd=.
local j=2002
while `j'<=2012{
egen rank`j'=rank(data2025) if closdate_year==`j'
egen perc`j'=pctile(rank`j'), p(50)
quietly replace cd=1 if rank`j'>=perc`j' & closdate_year==`j'
quietly replace cd=0 if rank`j'<perc`j' & closdate_year==`j'
drop rank`j' perc`j'
local j=`j'+1
}
sort id closdate_year
gen small=.
quietly by id: replace small = 1 if cd==0
replace small=0 if cd==1
However, I wish to split this based on values, not on percent. I am basicly giving splitting my data of banks into small and large based on the value of their total assets.
Thanks in advance!
Einar.
Comment