BookmarkSubscribeRSS Feed
SASAna
Quartz | Level 8

Hi SAS users,

 

I need help with writing this SQL correctly. I need to update/alter a table with status of 'SUCCESS/FAILURE'  based on the case condition .

 

UPDATE &SUM_TABLE A
SET
STAT = 'SUCCESS'      

             case WHEN ((B.INPUT_CNT - A.UNIQUE_CLAIM_ID)=0
                                     (SELECT COUNT(*) AS INPUT_CNT

                                                        FROM MANUAL_TEMP B)

                                       )
ELSE 'FAILURE'
END;

 

Thanks,

Ana

2 REPLIES 2
Ksharp
Super User
data have;
 length sex $ 20;
 sex='M';age=12;output;
 sex='F';age=1;output;
run;
proc sql;
update have as a
set sex=
 case 
 when (exists(select * from sashelp.class where age=a.age))
  then 'TRUE'
 else 'FALUSE' 
 end;
quit;


PGStats
Opal | Level 21

Proper syntax would be:

 

UPDATE &SUM_TABLE
SET
	STAT = case 
		when UNIQUE_CLAIM_ID = (SELECT COUNT(*) FROM MANUAL_TEMP)
			then 'SUCCESS'
			else 'FAILURE'
			end;

but I doubt that this is what you really want to do. I doesn't look right to equate a claim ID with the record count in another table. Could you explain what the SUCCESS/FAILURE condition is supposed to be?

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 11785 views
  • 1 like
  • 3 in conversation