turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- what does x4 do?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-04-2012 05:39 PM

data ek;

x1=5;

x2=6;

x3=7;

x4=(x1|x2|x3);

run;

x4=1 in output

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-04-2012 06:21 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-04-2012 06:31 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-04-2012 06:34 PM

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

x1=.;

x2=.A;

x3=.Z;

x4=(x1|x2|x3);

x4 will be 0.