Solved

comparing multiple variables equal to 1 in SAS

Posted on 2013-01-08
4
336 Views
Last Modified: 2013-01-09
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
Comment
Question by:morinia
  • 2
4 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
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

by:
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
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

by:morinia
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
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…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now