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;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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