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!
Related Posts with How to create a binary variable that identify whether another variable has duplicates in the dataset using Stata?*
bar chart comparing mean to a constant variableDear Stata Community, I am looking to create a bar graph similar to that below. For simplicity, I w…
Getting the current and future 1, 3, 6 month returnsHello. I am working on a finance thesis. I want to create current month returns from daily stock pri…
Npregress slow with large data-sets, small samplesHi there, Stata brethren. Recently I have been trying to use the new nonparametric regression featu…
loop for dummy variableI have many data sets in the format such as this one, however most are much longer. origin is just t…
change in sign and significance of linear term after adding quadratic and cubic termsHi all, I need your comments on change in sign and significance of linear term after adding quadrat…
Subscribe to:
Post Comments (Atom)
0 Response to How to create a binary variable that identify whether another variable has duplicates in the dataset using Stata?*
Post a Comment