BookmarkSubscribeRSS Feed
ssas
Calcite | Level 5
Hi,
i would like to know how many and 's or's we can use in a data step.
for example

data test1 test2 test3;
set soruce;
if type='a' or type= 'b3' or or type='a21' ................ then output test1;

/* loke wise how many or 's can i use with in a single if clause */

run;

thanks in advance

sams Message was edited by: sams1
3 REPLIES 3
deleted_user
Not applicable
Hi,

The answer is pretty much as many as you could possibily hope to use. No doubt there is a limit but I've never reached it. If you have a number of ORs or ANDs which gets anywhere near the limit I would suggest you need to code you data step differently.

I would however suggest, in the example you give, using the IN operator.

e.g.

if type in ('a' 'b3' 'a21') then output test1;

Hope that helps.
ssas
Calcite | Level 5
Excellent, many thanks for both of you.
My mind didn't striked about in operator.

Thanks for u r help
Bill
Quartz | Level 8
most probably quite a few ...

To reduce typing, consider

if type in ('a', 'a21', 'b3') then ...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1021 views
  • 0 likes
  • 3 in conversation