BookmarkSubscribeRSS Feed
crashz204
Calcite | Level 5

I have a table created in SAS with a list of values. I have a secondary table that I caluclated values on based on table 1.

I am wanting to update table 1 with the calculated values from table 2.

 

I use the following code.

 

PROC SQL;
update TEST_MAIN 
set (value_1) = (select calc1 from CR_CALC)
where FIELD= 'CR';
RUN;

 

This updated the VALUE_1 field with the data i need.

however, I have multiple fields to update so I used this example:

 

PROC SQL;
update TEST_MAIN 
set (value_1, value2) = (select calc1. calc2 from CR_CALC)
where FIELD= 'CR';
RUN;

 

I get this error:

_
22
76
ERROR 22-322: Expecting a name.

ERROR 76-322: Syntax error, statement will be ignored.

 

I'm not sure what the error is. I used this in SQL syntax all the time without issue.

Thank You!

1 REPLY 1
Tom
Super User Tom
Super User

Not sure what flavor of SQL you are used to using but that syntax is not supported in the SQL standard that PROC SQL uses.

Check out the documentation: https://documentation.sas.com/?docsetId=sqlproc&docsetTarget=p0ci36zwxhm1xdn1a943yeczfalk.htm&docset...

PROC SQL;
update TEST_MAIN 
set var_1= (select calc1 from CR_CALC)
  , var_2 = (select calc2 from CR_CALC)
where FIELD= 'CR'
;
RUN;

Make sure that the subqueries return one and only one value.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 12673 views
  • 0 likes
  • 2 in conversation