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

Can you exclude a row in a dataset in SAS?  I know you can do it in JMP but can't find anything about it in SAS. 

If the only option is to delete, how do I delete a row with specific variables?  For example, the two rows I want to delete have the following categorical variables.  This combination of variables makes those rows unique.  

Row 1: Loc = A, Hyb=X03, Ntrt = High, Density = Low

Row 2: Loc = B, Hyb = X04, Ntrt = Low, Density = Low

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
AMSAS
SAS Super FREQ

Something like this:

Data want ;
 set have ;
 if loc="A" and Hyb="X03" and Ntrt="High" and Density="Low" then delete ;
 if loc="B" and Hyb="X04" and Ntrt="High" and Density="Low" then delete ;
run; 

View solution in original post

3 REPLIES 3
AMSAS
SAS Super FREQ

Something like this:

Data want ;
 set have ;
 if loc="A" and Hyb="X03" and Ntrt="High" and Density="Low" then delete ;
 if loc="B" and Hyb="X04" and Ntrt="High" and Density="Low" then delete ;
run; 
Daisy2
Obsidian | Level 7
Thanks!
mklangley
Lapis Lazuli | Level 10
proc sql;
    delete from my_dataset
    where (Loc = 'A' and Hyb = 'X03' and Ntrt = 'High' and Density = 'Low')
       or (Loc = 'B' and Hyb = 'X04' and Ntrt = 'Low' and Density = 'Low');
quit;

Or, if you just want to exclude those rows:

proc sql;
    create table want as
    select *
    from my_dataset
    where not (Loc = 'A' and Hyb = 'X03' and Ntrt = 'High' and Density = 'Low')
       and not (Loc = 'B' and Hyb = 'X04' and Ntrt = 'Low' and Density = 'Low');
quit;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 5323 views
  • 0 likes
  • 3 in conversation