Hello, I want to fix the data errors in a long format data as follows,
clear
input str10 id byte state byte year byte gr byte K5G
001 0 1 0 1
001 0 2 1 1
001 0 3 2 1
001 0 4 3 1
001 0 5 4 1
001 . 6 . 0
002 0 1 0 1
002 . 2 . 0
002 0 3 2 1
end
Here the variable KG5 has data errors.
This variable indicates if a student is retained in kindergarten to the 5th grade, the variable indicates if a student is retained in a specific grade, and gr represents grade year.
It is obvious that the student with id==1 has data errors on the variable KG5, because within id, all K5G values should be coded as "missing values" for this person with id==1.
Similarly, the person with id==2 has the similar problem. All values of the KG5 variable should be equal to "missing values" within this person with id==2.
Can someone help me with Stata code?
Thank you!
clear
input str10 id byte state byte year byte gr byte K5G
001 0 1 0 1
001 0 2 1 1
001 0 3 2 1
001 0 4 3 1
001 0 5 4 1
001 . 6 . 0
002 0 1 0 1
002 . 2 . 0
002 0 3 2 1
end
Here the variable KG5 has data errors.
This variable indicates if a student is retained in kindergarten to the 5th grade, the variable indicates if a student is retained in a specific grade, and gr represents grade year.
It is obvious that the student with id==1 has data errors on the variable KG5, because within id, all K5G values should be coded as "missing values" for this person with id==1.
Similarly, the person with id==2 has the similar problem. All values of the KG5 variable should be equal to "missing values" within this person with id==2.
Can someone help me with Stata code?
Thank you!
