Solved

comparing multiple variables equal to 1 in SAS

Posted on 2013-01-08
4
347 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

948 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

17 Experts available now in Live!

Get 1:1 Help Now