I want to create two random dataset with 45,000 students. Students can be enrolled from 1st grade to 10th grade. Below is an example of what I am trying to do. I have eleven variables. The variable id is a student's unique id. The variables grade1, grade2, grade3, grade4, grade5, grade6, grade7, grade8, grade9, and grade10 represent the grade that a student is currently enrolled in. I stipulate that a student can only be enrolled in one grade.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id grade1 grade2 grade3 grade4 grade5 grade6 grade7 grade8 grade9 grade10) 1 0 1 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 0 0 3 0 0 0 1 0 0 0 0 0 0 4 0 0 0 0 0 0 1 0 0 0 5 0 0 1 0 0 0 0 0 0 0 6 0 0 0 0 1 0 0 0 0 0 7 0 0 0 0 0 0 0 0 1 0 8 0 0 0 0 0 1 0 0 0 0 9 0 0 0 0 0 0 1 0 0 0 10 0 0 0 0 0 0 0 0 0 1 end
1) How would I create this dataset of 45,000 students who are uniquely enrolled in one grade?
2) If I wanted to stipulate that 2,000 students in the sample are 5th graders, how would I create this dataset?
0 Response to Creating dummy variable and assigning a unique individual to one of many possible group
Post a Comment