BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jj02148
Obsidian | Level 7

Hi All,

 

I ran into a problem in which I need to write a long logic expression: A01=1 OR A02=1 OR A03=1 OR A04=1 OR... A15=1 then TF=1;

 

Not sure if there is an easy and quick way to write the code? Say, IF any of (A01--A15) =1 then TF=1?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

If you create an array holding the variables, there are two methods.  The array:

 

array alist {15} a01-a15;

 

Then you could search with:

 

if whichn(1, of alist{*}) then TF=1;

 

Surprisingly, this method also works (once the array is defined):

 

if 1 in alist then TF=1;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

If you create an array holding the variables, there are two methods.  The array:

 

array alist {15} a01-a15;

 

Then you could search with:

 

if whichn(1, of alist{*}) then TF=1;

 

Surprisingly, this method also works (once the array is defined):

 

if 1 in alist then TF=1;

jj02148
Obsidian | Level 7
Thanks so much!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 999 views
  • 2 likes
  • 2 in conversation