Good Morning Stata Members,
Below is an example of my data structure:
SchoolCode,CourseCode, V1, V2, V3,Program1,Program2,Program3,Program4
1,ERT23,10,12,2, 1,0,0,1
2,EMS45,5,6,11,0,1,0,1
1,MNT34,7,8,2,1,0,0,1
Each row is unique.
The example below is where I would like to go. A new row is generated if there is 1 in the Program Variable Colums
#1
SchoolCode,ProgramName,CourseCode,V1,V2,V3
1,Program1,ERT23,10,12,2
1,Program4,ERT23,10,12,2
2,Program2,EMS45,5,6,11
2,Program4,EMS45,5,6,11
1,Program1,MNT34,7,8,2,
1,Program,4,MNT34,7,8,2
#2 Sort
SchoolCode,ProgramName,CourseCode,V1,V2,V3
1,Program1,ERT23,10,12,2
1,Program1,MNT34,7,8,2
1,Program4,ERT23,10,12,2
1,Program,4,MNT34,7,8,2
2,Program2,EMS45,5,6,11
2,Program4,EMS45,5,6,11
#Sum by ProgramCode and SchoolCode -
SchoolCode,ProgramName,CourseCode,V1,V2,V3
1,Program1,57,17,20,4
1,Program4,57,17,20,4
2,Program2,EMS45,5,6,11
2,Program4,EMS45,5,6,11
Thanks in advance!
Related Posts with Transpose and Collapse
Temporary names and Mata matrix operationsDoes anyone know why the space after the row-join operator and before the tempname matrix matters in…
What is the prediction model to predict the probability?In a paper, Dasgupta, 2019 used Difference-in-Difference approach to see whether anticollusion laws …
Generate a new variable and assigns 1 after a value increases in other variable.Dear Statalist users, I've been still struggling for a few hours after I tried several commands sea…
Bayesian Posteriors (Direct Computation) HelpHello all, I am currently working on a project and some internal comments suggested that I directly…
Enter text in the top-left corner using collectHello, I've been learning how to make and export tables using the collect command, and I'm really e…
Subscribe to:
Post Comments (Atom)
0 Response to Transpose and Collapse
Post a Comment