BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8

data ek;

x1=5;

x2=6;

x3=7;

x4=(x1|x2|x3);

run;

x4=1 in output

3 REPLIES 3
joehinson
Calcite | Level 5

x4=(x1|x2|x3 ) is the same as x4=(x1 OR x2 OR x3)

which is TRUE and therefore 1 (because it is an assignment statement and will always be true).

Furthermore, any number OR'ed with another number   would give 1, except (0 OR 0) which would give 0.

So, (34 OR 987765)=1

Reeza
Super User

It won't always be true, what if all are 0?

In SAS false is 0 and anything else is true.

data ek;

x1=0;

x2=0;

x3=0;

x4=(x1|x2|x3);

put x4;

run;

Astounding
PROC Star

Also, don't forget missing values are also false.

x1=.;

x2=.A;

x3=.Z;

x4=(x1|x2|x3);

x4 will be 0.

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