My data consists of multiple rows for each person. I want to keep the rows if the followup=0 or if followup is between 2.5 and 3.5.
My data looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex
* dataex naccid Followup
clear
input str10 naccid float Followup
"NACC000011" 0
"NACC000011" 1.169863
"NACC000011" 2.131507
"NACC000011" 3.29863
"NACC000271" -1.9013698
"NACC000271" -.9178082
"NACC000271" 0
"NACC000271" 1.2
"NACC000271" 2.2931507
"NACC000271" 3.410959
"NACC000304" 0
"NACC000304" .9972603
"NACC000304" 2.0465753
"NACC000304" 2.972603
"NACC000304" 3.991781
"NACC000304" 5.021918
"NACC000304" 6.364384
"NACC000382" 0
"NACC000382" 1
"NACC000382" 1.9945205
"NACC000382" 3.068493
"NACC000382" 4.5068493
end
drop if Followup <!2.5>!3.5 & Followup !=0
drop if Followup <2.5 | Followup >3.5 | Followup !=0
So essentially for NACC000011, I want to keep rows 1 and 4; and for NACC000271 rows 7 and 10, for NACC000304 rows 11 and 14 so on...
Any suggestions?
0 Response to Dropping observations based on multiple conditions
Post a Comment