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.
That query makes no sense to me. What are you trying to do? - PG
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.
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
it perfectly works. But would like to understand whats wrong in using CALCUALTED variable like that
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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.