Solved

# comparing multiple variables equal to 1 in SAS

Posted on 2013-01-08
377 Views
I have variables JAN, FEB, MAR, APR, MAY ........DEC
Is there a simple way to see if each of the respective variables is = 1 without using multiple "If statements"?
0
Question by:morinia
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 143

Assisted Solution

Guy Hengel [angelIII / a3] earned 150 total points
ID: 38758197
you can put several conditions:

IF (JAN = 1 AND FEB = 1 AND MAR = 1 ... etc .. )
0

LVL 14

Accepted Solution

Aloysius Low earned 150 total points
ID: 38758833
are you looking for something like angelIII's answer or something else? if something else, could you be more specific about what you want?

a simple way, which is an alternative to angelIII's solution, is if you want to check if all variables holds value 1 is to do a sum, which if is anything but 12 would mean that one of the variables is not 1.
0

LVL 143

Expert Comment

ID: 38759173
>is if you want to check if all variables holds value 1 is to do a sum, which if is anything but 12

well, that depends ...
if the values can be 0 and 1 only, yes, that will work.
if they can have other values also, this logic will eventually fail.
6x2 + 6x0 will give 12 also.

IF the values are all integer, then you could do the multiplication of all the values... and the result being 1 would imply all 12 values to be 1. if any was 0, the result would be 0, if any was > 1 otherwise, the result would be >1 ...
0

Author Comment

ID: 38759263
Thanks angelIII for the breakdown.  You are correct.  However, in this example I only have 0 and 1 in the field.  The field is initialized to 0 and updated to 1 if a criteria is met.

Your analytical breakdown is good to keep in mind, especially if there can be other values in the field.

Thanks again for the catch.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Read about achieving the basic levels of HRIS security in the workplace.
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of demâ€¦
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦
###### Suggested Courses
Course of the Month4 days, 1 hour left to enroll