BookmarkSubscribeRSS Feed
PrakashBashyam
Calcite | Level 5

Hi

I m using below query


proc sql;

update Work.Sim_re_BERM

set L9BE_C=max(0,L9_C*(L9BE/L9)),

L9RM_C=L9_C - calculated L9BE_C;

Quit;

This is throwing an ERROR: The illegal use of a CALCULATED variable has been detected in an UPDATE statement.


5 REPLIES 5
PGStats
Opal | Level 21

That query makes no sense to me. What are you trying to do?   - PG

PG
PrakashBashyam
Calcite | Level 5

Sorry, I am not getting your questions

L_* are columns of the table Work.Sim_re_BERM.

Setting L9BE_C based on calculation max(0,L9_C*(L9BE/L9))

And L9RM_C based difference between L9_C on CALCUALTED L9BE_C.

PGStats
Opal | Level 21

OK, maybe I get it now. Have you tried getting rid of CALCULATED :

proc sql;

update Work.Sim_re_BERM

set

     L9BE_C = max(0, L9_C*(L9BE/L9)),

     L9RM_C = L9_C - max(0, L9_C*(L9BE/L9));

Quit;


PG

PG
PrakashBashyam
Calcite | Level 5


it perfectly works. But would like to understand whats wrong in using CALCUALTED variable like that Smiley Sad

PGStats
Opal | Level 21

SQL is a formal language with very strict syntax. That is very different from natural languages which are much more flexible but also more prone to misinterpretation. I think the UPDATE query is made such that every assignment (L9BE_C =, L9RM_C =, etc) clause can be treated separately (and thus, in parallel).

PG

PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1684 views
  • 0 likes
  • 2 in conversation