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

I hope it is clear what I want to do without code: 

I have a date set, and if one condition is true then I want to delete that row. If it is not true, then I don't want to do anything with the data, just let it be what it is. 

How could I achieve this? 

Thanks. 

1 ACCEPTED SOLUTION
3 REPLIES 3
mklangley
Lapis Lazuli | Level 10

Here's a simple example, just to illustrate:

data have;
    input name $ age;
    datalines;
Allen 12
Bob 23
Charles 34
Doug 45
Edward 56
    ;
run;

title 'Before:';
proc print data=have; run;

data want;
    set have;
    if name = 'Bob' then delete;
run;

title 'After:';
proc print data=want; run;
Tom
Super User Tom
Super User

To use with a subsetting IF just invert the test.

   if name = 'Bob' then delete;

is the same as

   if not (name = 'Bob') ;

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
  • 924 views
  • 4 likes
  • 4 in conversation