Lets say I want to update table A based on a column in table B. Table B will have a list of games (like A, B, C, D) and if those games are in table A, I want to decrease a certain value. if I do
proc sql ;
update A set value=value-1
where game in (select game from B)
;
quit;
if dataset B has a game listed more than once, will the value decrease more than once? IE if its listed twice, the value in dataset A will decrease by 2.
You could make it execute by adding the UPDATE_POLICY=NONE but why? If you leave it coded the way it is the update will happen for every row as every value of GAME in dataset A is by definition in dataset A.
and one more question, if I wanted to do the same thing, but using simply another column in table A, is that possible? When I try it by changing B to A, it says sql cant use the table it is updating to update.
You could make it execute by adding the UPDATE_POLICY=NONE but why? If you leave it coded the way it is the update will happen for every row as every value of GAME in dataset A is by definition in dataset A.
I realize by you saying that I am looking at this in the wrong way in terms of my goals. Anyways, thx for the help.
No. It will process each row in A and decide whether that GAME exists in B, if it does it will execute the update.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.