Dear reader,
for a project we need to make a regression where we control for industry*year fixed effects. We use 282 sic codes and 1977-2015 as period. We created the following loop:
gen industry = Ac3SIC
encode industry, gen(test)
gen year=year(date)
forvalues a = 1977(1)2015 {
forvalues b = 1(1)288 {
gen y`a'i`b' = 0
replace y`a'i`b' = 1 if year==`a' & test==`b'
foreach var of varlist y`a'i`b' {
sum y`a'i`b', meanonly
if r(mean) == 0 {
drop y`a'i`b'
}
}
}
}
This resulted in almost 4000 dummy variables. For our regression we want to make a categorical variable which replaces those 4000 dummy variables. Can anyone help us with this? Or is there an other way how we should approach this?
Kind Regards,
Jan Blokland
Related Posts with Creating one variable from multiple dummy variables
Zip could not be opened - r(603) (maptile)Good afternoon, I have tried to find a similar topic regarding this specific problem on this forum…
Time series portfolio betasHey everyone, For my thesis I am following the methodology from Dittmar & Lundblad (2017) to ob…
How do I drop dates => than 01.may 2013?When I write: drop if=>01may2013 stata replices "01may2013 invalid name" …
How do I drop dates later than 01.may 2013When I write: drop if=>01may2013 stata replices "01may2013 invalid name" …
Fixed Effect variablesHello Statalist I want to perform a logit regression using various variables (not fixed effects) bu…
Subscribe to:
Post Comments (Atom)
0 Response to Creating one variable from multiple dummy variables
Post a Comment