Hi all,
Complete newbie here. I've been trying to figure out the following without success. My set of data contains a variable X with observations that repeat (i.e., the number of times the same person had different observations). I'm trying to figure out how to keep only the last observation in my data set.
It looks something like this:
X Y Z
6 Yes 10/31/1990
3 No 2/10/2010
3 No 2/28/2020
4 No 5/30/2016
6 No 12/10/2020
Observations 6 and 3 repeat for X. I only want to keep the last observations in X (while keeping everything else). My hope is that after keeping only the last observations of X, I will be left with something like this:
X Y Z
3 No 2/28/2020
4 No 5/30/2016
6 No 12/10/2020
Any help would be much appreciated!
Related Posts with Keeping Last Observation
Simultaneously run through two forvalues loopsDear statalist, I'm trying to program the following commands more mechanically: Code: rename inte…
Drop if ALL specified variables fulfill a certain conditionDear statalist, is there a way to write the following command Code: drop if intention1==9 & i…
Adding extra years to an existing date variableDear Statalist, I have a date variable created the following way: Code: gen PartDat_gli = . repl…
Adding options to a package (.ado)Hi everyone, I have written a code to run the LFK index (Int J Evid Based Healthc. 2018 Dec;16(4):1…
Rename variables to remove part of the textDear Statalists, I have the following variables and would like to rename them to remove untitled###…
Subscribe to:
Post Comments (Atom)
0 Response to Keeping Last Observation
Post a Comment