BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yuwda01
Calcite | Level 5

Hi,

 

How to un-select (delete) records in data step?

I have 100 records type in input and I want to skip any data with name started with ABC or DEF or GHI. 

 

Thanks David

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

HAVE is the input sample I created for demonstration

 

You could also use boring substr function to achieve the same

 

data want;
set have;
where substr(var,1,3) not in ('ABC','DEF','GHI');
run;
if substr(var,1,3) not in ('ABC','DEF','GHI');

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20
data have;
input var $10.;
cards;
ABCrwe
DEFte
GHIgteg
dfserg
bfgdxbh
vxfgnb
vsdrgf
;

data want;
set have;
if var not in :('ABC','DEF','GHI');
run;

 You could use WHERE as well

where var not in :('ABC','DEF','GHI');

 

yuwda01
Calcite | Level 5
Sorry, the input are done on the previous step and it created temp data.

Now I need to use temp data to create another temp1 data without those data I want to skip.



Thanks David


novinosrin
Tourmaline | Level 20

HAVE is the input sample I created for demonstration

 

You could also use boring substr function to achieve the same

 

data want;
set have;
where substr(var,1,3) not in ('ABC','DEF','GHI');
run;
if substr(var,1,3) not in ('ABC','DEF','GHI');
yuwda01
Calcite | Level 5

yes, it works...   Thanks for the advice.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 1016 views
  • 0 likes
  • 2 in conversation