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
Create a duplicates drop logic working for missing valueHi Statalisters, I am working on my data cleaning and have such a problem. When I use duplicat…
Testing for Non-linearity in Fixed EffectsHello, I am running individual FE models where my dep variable (DV) is treated as continuous but it…
Dropping duplicates based on another variableI have a large dataset with patient encounters, of which some patients may have had multiple encount…
Changing variable names on a forest plot STATA 15.1Ok so i have ran a mata analysis odds ratio and created a forest plot,i have what i need on the grap…
svmachinesI am trying to run svmachines command and this syntax, when I run this in CV and Test predictions I …
Subscribe to:
Post Comments (Atom)
0 Response to Creating one variable from multiple dummy variables
Post a Comment