Dear Statalisters,
I work on a database in which results of an enterprise survey (multiple choice questions) are collapsed into the sum of options chosen by the respondents within an enterprise. Example: In first row, within firm “A”, 9 respondents chose opt1; 7 chose opt2; and 8 chose opt3.
clear
input str6 firm_id byte (opt1 opt2 opt3)
"A" 9 7 8
"B" 15 5 8
"C" 3 6 3
"D" 4 3 3
"E" 10 6 2
What I need is to disaggregate each total into single records. My code is:
expand opt1 if firm_id=="A"
replace opt1=1 if firm_id=="A"
Maybe there is a better way to do it. Also, I need to create a loop with foreach over 220 variables and 500 enterprises.
Thank you,
Iciar Pavez
Related Posts with Expanding observations
Poisson Regression with Hausman Taylor instrumental variables estimatorI have a panel data. The dependent variable is a count variable, so a Poisson regression is more app…
R-sqaured in multilevel analysisHi! For multilevel analysis, do you recommend to use AIC instead of mltrsq (Snijders-Bosker R-Square…
Graph trend time DID xtregDear Stata users, I want to obtain a similar graph, that is commonly used to analyse trends in diffe…
Very high numbers when holding time fixed in regressionHi everyone, I am not sure if this is a coding question or not, but maybe I do something wrong when…
DateI am trying to generate a date in my work. I am only working with year intermissions between dates f…
Subscribe to:
Post Comments (Atom)
0 Response to Expanding observations
Post a Comment