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
[DUVIDA] Separar valores de uma variávelOlá pessoal, preciso extrair para uma nova coluna os dois primeiros dígitos de uma variável. Por exe…
duplicate dataHello, so i have to summarize some investmentfunds that kinda look like this: fundid fundnr isin c…
Fractional response with censored zerosDear Statalist community, I am doing research using insurance claim data, where the dependent varia…
Passing from monthly to yearly returns firm_id date ret 10001 11/30/2015 -0.00907 10001 12/31/2015 -0.13215 10001 01/2…
Weighted average for panel groups and subperiodsDear all, I have an unbalanced panel, which contains group, where I have also generated some custo…
Subscribe to:
Post Comments (Atom)
0 Response to Creating one variable from multiple dummy variables
Post a Comment