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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 886 views
  • 0 likes
  • 2 in conversation