Hi,
I would like to delete all rows for IDs who only have 0s for var
So, in the example below, I would delete all rows for ID#2.
Somehow, I have to read all obs in each by group and then flag those who only have 0 but having trouble finding how..
Thanks very much!!
Have
Want
ID
var
1
0
2
3
Sql
select from table
where id not in ( select id from table group by ID having max(var) = 0 );
Hello @antona, welcome to the Community!
Is var numeric or alphanumeric?
If it is alphanumeric try:
data killList; set have; by id; retain onlyZeros; if first.id then onlyZeros = 1; if var = '1' then onlyZeros = 0; if last.id and onlyZeros then output; keep id; run; data want; merge have killList(in= removeIt); by id; if removeIt then delete; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Submit your idea!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.