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?*
why categorical variables regression only shows one group result?Hey, I am running a regression with categorical variables. But I am quite confused why it only show…
creating loopHi, I am new in stata, so I am doing long commands for a simple variable generating. I want to short…
How get variable list for a conditionI wonder if its possible get a variable list for a condition, example: Code: clear all sysuse auto…
Problem in reporting Arellano-Bond test for auto-correlation after xtabond2Hello dear Stata Users, I am estimating a dynamical panel (370 firms; T=10) where my dependent var i…
bootstrap test for a multilevel mediation analysisDear all, I'm trying to perform a 2-2-1 multilevel analysis, and my DV is binary. I used the comman…
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