data have;
input id Cd $ flg $ DATE1 DATE9. ;
format date1 date9.;
datalines;
11 chg b 13apr2019
11 chg i 11apr2019
12 chg e 6may2017
13 chg b 5jun2019
14 add d 4mar2019
14 chg y 1jan2019
;run;
I want to eliminate all rows where the number of rows per id is more than 1. So In this example I would eliminate 11 and 14 and only keep 12 and 13. Using a proc sort nodupkey would not work in this case.
So only keep the IDs that do NOT have multiple rows?
data want;
set have;
by id;
if first.id and last.id;
run;
data have;
input id Cd $ flg $ DATE1 DATE9. ;
format date1 date9.;
datalines;
11 chg b 13apr2019
11 chg i 11apr2019
12 chg e 6may2017
13 chg b 5jun2019
14 add d 4mar2019
14 chg y 1jan2019
;
proc sort data=have nouniquekeys uniqueout=singles ;
by id;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.