BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Xamius32
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

4 REPLIES 4
Xamius32
Calcite | Level 5

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.

Tom
Super User Tom
Super User

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.

Xamius32
Calcite | Level 5

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.

Tom
Super User Tom
Super User

No.  It will process each row in A and decide whether that GAME exists in B, if it does it will execute the update.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1160 views
  • 3 likes
  • 2 in conversation