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
Stata Export over EXCEL's row limitHi All, 1,048,576 is the max row limit for excel. So if you have STATA data over this limit and wan…
Clique identification within larger networkI am interested in identifying cliques of entities (think of groups of common friends within a socia…
Merge if mergeHi, I have used the command "merge", creating a new var called "epr" instead of "_merge": merge m…
lagged variablesHi, I have a variable for gdp and for survey wave. I have three survey years and for each survey wav…
FMM errorI have the following estimation command using fmm: > fmm 3: regress $Y $T $X where $Y $X and $T…
Subscribe to:
Post Comments (Atom)
0 Response to Expanding observations
Post a Comment