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;
April 27 - 30 | GAYLORD TEXAN
Register now to lock in early bird pricing through February 25!
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.