I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.
It would ultimately be used within a CASE WHEN statement.
Proc SQL;
select
PAT_ID,
COL2, COL3, COL4, COL5, COL6, COL7,
CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS
FROM data;
quit;
Mathematical logic alternatives
The third option is probably the easiest. If you run into floating point errors you may want to use a ROUND to ensure it doesn't happen or FUZZ but the idea is as follows:
CASE WHEN sum(col3, col4, col5, col6, col7) = 0THEN 1 ELSE 0 END ZEROS
@PharmlyDoc wrote:
I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.
It would ultimately be used within a CASE WHEN statement.
Proc SQL; select PAT_ID, COL2, COL3, COL4, COL5, COL6, COL7, CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS FROM data; quit;
Mathematical logic alternatives
The third option is probably the easiest. If you run into floating point errors you may want to use a ROUND to ensure it doesn't happen or FUZZ but the idea is as follows:
CASE WHEN sum(col3, col4, col5, col6, col7) = 0THEN 1 ELSE 0 END ZEROS
@PharmlyDoc wrote:
I would like to see if multiple columns all contain '0' without having to use multiple 'AND' Statements.
It would ultimately be used within a CASE WHEN statement.
Proc SQL; select PAT_ID, COL2, COL3, COL4, COL5, COL6, COL7, CASE WHEN ((COL3 = 0) AND (COL4=0) AND (COL5=0) AND (COL6=0) AND (COL7=0)) THEN 1 ELSE 0 END ZEROS FROM data; quit;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: