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?*
Simpson paradox, how to visualize positive tendency when the coefficient doesnt outweigh absolute coefficient of the neg. general tendency?Hi everyone, I would like to have your opinion of the following. I am performing a regression on th…
Problem with generating and replacing variableHi, I have written the following code but I am facing a lot of problems. Code: gen tetns_inj=. …
Identifying coworkers in spell dataI have a dataset of worker employment spells, and I would like a general way to identify an individu…
Calculate median collecting observations from different variables in wide formatDear all, my data structure looks like this. good 1 price 1 good 2 price 2 etc. milk 43 egg 4…
Expanding Observations on Panel dataI have the following data: Code: * Example generated by -dataex-. To install: ssc install dataex …
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