The dataset is laid out in longitudinal format where the patient id (pid) is the first column, and the second column "PE"is if
the patient received duplicated physical check-up during their hospital stay. I want to create a new variable "RE" that can achieve
the goal like this: if PE has duplicates, then RE=1; If not, RE=0.
* Example generated by -dataex-.
clear
input byte (pid PE)
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 3
3 1
3 1
3 2
3 3
4 1
4 1
4 2
4 3
end
Thank you for your help!
0 Response to How to create a binary variable that identify whether another variable has duplicates in the dataset using Stata?*
Post a Comment