Hi,
I have dataset a
ID Version Session_A SetA SetB
1 2234 2234 1
1 2234 2236 1
2 3345 3345 1
2 3345 3367 1
3 4456 4456 1
4 5568 5568 1
5 5568 5523 1
I would like to delete all the setB which has SetA=1 with same Version
output dataset B:
ID Version Session_A SetA SetB
3 4456 4456 1
4 5568 5568 1
5 5568 5523 1
thanks in advance
Repeating a request that has already been made to you:
Please provide data as working SAS data step code from now on. You can follow these instructions or type the working SAS data step code yourself. Doing this avoids us having to make assumptions or guesses about your data (which might be incorrect), which makes it much more likely that people can provide correct answers; this helps you and helps us.
Does the ID variable have any role in selection? It is not described as such.
Why are you mentioning SetB? I don't see where SetB has any impact on the output.
Are there values for SetA other than 1 and Missing? Is SetA numeric or character? (Need to have the correct variable type to write a test for values that does not create errors or data conversion messages)
data have;
input ID Version Session_A SetA SetB;
cards;
1 2234 2234 1 .
1 2234 2236 . 1
2 3345 3345 1 .
2 3345 3367 . 1
3 4456 4456 . 1
4 5568 5568 . 1
5 5568 5523 . 1
;
proc sql;
create table want as
select * from have
group by id ,version
having not (max(seta)=1 and max(setb)=1);
quit;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.