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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 13494 views
  • 0 likes
  • 2 in conversation