BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
data apple;
set lemon (in=1);
if a then country='MAC";
where samp ~=' ' and account ~= ' ' and index(applepie,'apple');
length score $20.;
score_type=40;
run;

hi can you explain the statement 'where samp....'

we are not too sure how the index statement is working here either.. thanks

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

~= means Not Equal To .

HeatherNewton
Quartz | Level 8
yes we are aware of that, what we dont get is output of the index function, is it gonna be true or false?
also if the three conditions of where statement are all true, the line below where statement will run?
if where conditions not met, the line below where statement wont run?
LinusH
Tourmaline | Level 20

Yes, it will be evaluated for True or False. In SAS, anything else than 0 is considered True.

Where statement doesn't affect logic in your data step, it will filter data to be executed by the data step as a whole.

To control logic use the IF statement.

Data never sleeps
LinusH
Tourmaline | Level 20

Yes, it will be evaluated for True or False. In SAS, anything else than 0 is considered True.

Where statement doesn't affect logic in your data step, it will filter data to be executed by the data step as a whole.

To control logic use the IF statement.

Data never sleeps
andreas_lds
Jade | Level 19

if where conditions not met, the line below where statement wont run?

Exactly and it doesn't matter where you have the where statement in the data step. So you should put the where statement directly after the set statement to avoid confusion.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 694 views
  • 2 likes
  • 4 in conversation