Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

comparing multiple variables equal to 1 in SAS

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
morinia
Asked:
morinia
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you can put several conditions:

IF (JAN = 1 AND FEB = 1 AND MAR = 1 ... etc .. )
0
 
Aloysius LowCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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
 
moriniaAdvanced Analytics AnalystAuthor Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now