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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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