'Use PROC SQL to select null when two conditions are met

I am running a code where i am creating a table by taking all the columns from a table and then adding two columns from a second table. In the case when the two values coming from the second table are equal to 0 i need to set them to null. I can have other combinations such as FIELD1 = 0 and FIELD1 = 1 for example but not both equal to 0.

I am using PROC SQL like this:

PROC SQL;
    CREATE TABLE TABLEA  AS 
        SELECT A.*,
            CASE 
                WHEN (B.FIELD1 NE 0 AND B.FIELD2 NE 0)
                THEN B.FIELD1
            ELSE .
            END 
        AS FIELD1,
            CASE 
                WHEN (B.FIELD2 NE 0 AND B.FIELD1 NE 0)
                THEN B.FIELD2
            ELSE .
            END 
        AS FIELD2
            FROM TABLE1 AS A
                LEFT JOIN TABLE2 AS B ON A.ID = B.ID;
QUIT;

The code i am showing is not working, i still see a lot of records where FIELD1 = 0 and FIELD2 = 0 in the resulting table TABLEA.

What am i missing here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source