Hi Community,
I wanted your help in the following issue.
data dsn;
input ID $1. Seq $4. Group $5.;
cards;
1 01 BC
1 02 BC
2 00 LC
3 01 BC
3 02 LC
4 00 BC
5 01 BC
5 02 KC
5 03 BC
5 04 KC
;
run;
I want to delete all the ID's which have group other than BC. Not just the row but all the rows of that ID.
Thank you for your time and Help.
There are a few possibilities This one assumes your data is sorted as indicated in your sample data:
data want;
merge have have (where=(group ne "BC") in=delete_these);
by id;
if delete_these then delete;
run;
There will be a message about a many-to-many merge, but the result will still be correct.
There are a few possibilities This one assumes your data is sorted as indicated in your sample data:
data want;
merge have have (where=(group ne "BC") in=delete_these);
by id;
if delete_these then delete;
run;
There will be a message about a many-to-many merge, but the result will still be correct.
data dsn;
input ID $1. Seq $4. Group $5.;
cards;
1 01 BC
1 02 BC
2 00 LC
3 01 BC
3 02 LC
4 00 BC
5 01 BC
5 02 KC
5 03 BC
5 04 KC
;
run;
proc sql;
create table want as
select *
from dsn
group by id
having max(upcase(Group) ne 'BC')=0
order by id, seq;
quit;
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.