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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1939 views
  • 0 likes
  • 5 in conversation