Help using Base SAS procedures

request to know how many and or can be used with in a single if clause

Reply
Contributor
Posts: 43

request to know how many and or can be used with in a single if clause

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
N/A
Posts: 0

Re: request to know how many and or can be used with in a single if clause

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.
Contributor
Posts: 43

Re: request to know how many and or can be used with in a single if clause

Posted in reply to deleted_user
Excellent, many thanks for both of you.
My mind didn't striked about in operator.

Thanks for u r help
Super Contributor
Posts: 291

Re: request to know how many and or can be used with in a single if clause

most probably quite a few ...

To reduce typing, consider

if type in ('a', 'a21', 'b3') then ...
Ask a Question
Discussion stats
  • 3 replies
  • 92 views
  • 0 likes
  • 3 in conversation