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 ...

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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