BookmarkSubscribeRSS Feed
asalunkh
Calcite | Level 5

Hello

 

I am trying to insert data into my table using the case-when statement, however I am getting a syntax error.

Here's what I am trying to do:

 

proc sql;

insert into temp1 (x,y,z)

values(

case when condition 1 then a

        when condition 2 then b

        else c

        end as x,

case when condition 3 then c

        when condition 4 then d

        else e

        end as y,

case when condition 5 then f

        when condition 6 then g

        else g

        end as z)

run;

 

Thank you.

4 REPLIES 4
LinusH
Tourmaline | Level 20

This looks like pseudo code. Also, why don't you share the log/error message?

You can't expect us to help you if don't give us the means to do it.

Data never sleeps
PGStats
Opal | Level 21

Where is the data involved in the different conditions?

PG
ballardw
Super User

@PGStats wrote:

Where is the data involved in the different conditions?


 

coming from?

andreas_lds
Jade | Level 19
Proc SQL ends with quit not run. For such tasks I always use a data-step, avoiding ugly SQL code.