Hello, Folks,
I have a small dataset like this,
clear
input byte (id year gr kg5 k68 k912)
1 1 0 0 0 0
1 2 1 0 0 0
1 3 2 0 0 0
1 4 3 0 0 0
1 5 4 0 0 0
1 6 5 0 0 0
1 7 6 0 0 0
1 8 7 0 0 0
1 9 8 0 0 0
1 10 9 0 0 0
1 11 . 0 0 0
1 12 9 0 0 0
1 13 10 0 0 0
2 1 0 0 0 0
2 2 1 0 0 0
2 3 2 0 0 0
2 4 3 0 0 0
2 5 4 0 0 0
2 6 5 0 0 0
2 7 6 0 0 0
2 8 7 0 0 0
2 9 8 0 0 0
2 10 9 0 0 0
2 11 10 0 0 0
2 12 . 0 0 0
2 13 9 0 0 0
3 1 0 0 0 0
3 2 . 0 0 0
3 3 . 0 0 0
3 4 . 0 0 0
3 5 . 0 0 0
3 6 . 0 0 0
3 7 . 0 0 0
3 8 . 0 0 0
3 9 . 0 0 0
3 10 9 0 0 0
3 11 . 0 0 0
3 12 . 0 0 0
3 13 9 0 0 0
4 1 0 0 0 0
4 2 . 0 0 0
4 3 . 0 0 0
4 4 . 0 0 0
4 5 . 0 0 0
4 6 . 0 0 0
4 7 . 0 0 0
4 8 . 0 0 0
4 9 8 0 0 0
4 10 . 0 0 0
4 11 10 0 0 0
4 12 9 0 0 0
4 13 10 0 0 0
5 1 0 0 0 0
5 2 1 0 0 0
5 3 2 0 0 0
5 4 3 0 0 0
5 5 4 0 0 0
5 6 . 0 0 0
5 7 4 0 0 0
6 1 0 0 0 0
6 2 1 0 0 0
6 3 2 0 0 0
6 4 3 0 0 0
6 5 4 0 0 0
6 6 5 0 0 0
6 7 6 0 0 0
6 8 8 0 0 0
6 9 . 0 0 0
6 10 7 0 0 0
end
please run the Stata code below to remove extra variables in the data set,
drop k*
The student with ID==6 is a demoted student, as can be seen from the data, the student went back to 7th grade after finishing 8th grade.
The student with ID=3/5 is just a regular student who repeated grades.
As for the students with ID=2/4, the student is both a repeated student and a demoted student.
All scenarios above were regarded as "REPEATED".
What I want is to correctly use a binary variable "REPEATED" indicating if a student repeated grades in a specific grade (REPEATED==1; REPEATED==0; if gr is missing value, then REPEATED==missing value).
Thanks for your Stata code!
Related Posts with How to Mark the Demoted Students Out in Long Format Data in Stata?
New program -ineqdecgini- (Gini coefficient and its subgroup decomposition) now available on SSC-ineq …
stata commandI have several observations (individuals) with each belong to a household (so each has a household I…
How to find lag of a variable in long format panel dataset?I have a dataset akin to this User Date Value A 2012-01-01 4 A 2012-01-02 5 A 2012-01-03 6 A 2012-0…
Create a new column using a column of 1 and 0.Hello! I'd like to ask for advice. I have the following data: I want to make a "var2" using "var1". …
qreg alternate solutions exists - retrieve solutionsHi, I am running a simple quantile (median) regression that has a dummy variable on the RHS. The y-…
Subscribe to:
Post Comments (Atom)
0 Response to How to Mark the Demoted Students Out in Long Format Data in Stata?
Post a Comment