BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

Need help to tackle this update statement? It's not working now due to unexcepted Select statement error in the SET statement.

 

UPDATE XF.POS_PROC_COD_TEST PCI
SET PCI.PROC_CD_DESC  = 
FROM (
	SELECT 
		PDC.id,
		max(
			CASE WHEN ( COALESCE(SERVICE_FROM_DT, TO_DATE('20990101', 'YYYYMMDD')) ) BETWEEN EFFECTIVE_DATE AND 
			 (CASE WHEN EXPIRATION_DATE IS NULL THEN '2099-01-01' ELSE EXPIRATION_DATE END)
			 THEN DESCRIPTION END) PROC_CD_DESC_NEW
	FROM XF.POS_PROC_COD_TEST PDC
	LEFT JOIN XF.POS_CLAIM_HEDR TPCC ON PDC.O_CLAIM_ID = TPCC.O_CLAIM_ID                   
	LEFT JOIN (
		SELECT DISTINCT ICD_PROC_CODE, EXPIRATION_DATE,EFFECTIVE_DATE, DESCRIPTION  FROM
		COM_DB.COM_DATA.MR_ICD_PROC) CDMRIP
		ON CDMRIP.ICD_PROC_CODE = PDC.PROC_CD
	GROUP BY PDC.id
) Q1
WHERE PCI.id = Q1.id and PCI.id = 0411;
8 REPLIES 8
ballardw
Super User

How about showing the LOG with the code and the actual text of the error message and diagnostic characters plus any other notes or warnings.

 

And if this is connecting to an external data base (i.e. not using SAS data sets) perhaps include the connection options.

Babloo
Rhodochrosite | Level 12

@ballardw Statement is not valid error. I want to know what is wrong with the SET statement.

 

@Kurt_Bremser  any help you can offer here?

ballardw
Super User

@Babloo wrote:

@ballardw Statement is not valid error.


What does "not valid error" mean?   Just because you don't know why it is an error does not mean it is not an error.

We don't have any of your so can't run the code.

The use of the "dates" that you show pretty much implies you are working with something other basic SAS data sets, so the question may well be in that system and not SAS.

Kurt_Bremser
Super User

Something like

TO_DATE('20990101', 'YYYYMMDD')

can only be valid in some other, non-SAS SQL dialect, so it would have to be part of explicit pass-through.

Once again, post the complete log.

Babloo
Rhodochrosite | Level 12
I don't have log at the moment. Is it right the way to use case when with
select in the proc sql update statement?
Mazi
Pyrite | Level 9

I don't think your syntax is correct.

 

if you're using proc sql without passthru facility the syntax would look something like this:

 

data test;
	set sashelp.class;
	age=.; **Set age to missing and update using sql query;
run;

proc sql;
	update test a
		set age = (select age from sashelp.class b where a.name = b.name);
quit;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 8 replies
  • 470 views
  • 1 like
  • 4 in conversation