Hello,
I previously received help generating an indicator variable that would take the value of all possible combinations of a list. In order that the name of the indicator would correspond with what it represented, I used this command:
Where f = female, n = native, w = white, y = age<=25, and s = single. Now, instead of 31 indicators, I'm trying to generate one categorical variable that will take the corresponding value for all observations. My intutition is to do the following:
and then use the egen command, but having trouble finding out how I would correctly do this.
Thank you.
I previously received help generating an indicator variable that would take the value of all possible combinations of a list. In order that the name of the indicator would correspond with what it represented, I used this command:
Code:
gen byte f = sex==2 gen byte n = bpl<=99 gen byte w = race==1 & !inlist(hispan,1,2,3,4) gen byte y = age<=25 gen byte s = inlist(marst,3,4,5,6) forval f=0/1 { forval n=0/1 { forval y=0/1 { forval w=0/1 { forval s=0/1 { gen cat_f`f'_n`n'_y`y'_w`w'_s`s'= /// (f==`f')*(n==`n')*(y==`y')*(w==`w')*(s==`s') } } } } }
Code:
generate ct = 1
Thank you.
Comment