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

Hi all,

I would like to update several columns in a table from their

counterparts in another table.

If I only wanted to update one variable I could do :

UPDATE T1

SET X = (

     SELECT X

     FROM T2

     WHERE T2.ID=T1.ID

);

What if I also want to update variable Y ? Is there a way to achieve the result

with only one select ?

I tried the following with no luck :

UPDATE T1

SET (X,Y) = (

    SELECT X, Y

    FROM T2

    WHERE  T2.ID=T1.ID

);

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

I am usually a fan of SQL, but when it comes to update syntax, no...

To my knowledge, you need multiple SELECTs to do this.

So, I would suggest to use a data step update, using MODIFY. Should cover most scenarios of updating using a transaction table.

Data never sleeps

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20

I am usually a fan of SQL, but when it comes to update syntax, no...

To my knowledge, you need multiple SELECTs to do this.

So, I would suggest to use a data step update, using MODIFY. Should cover most scenarios of updating using a transaction table.

Data never sleeps
gamotte
Rhodochrosite | Level 12

OK, I reached the same conclusion by searching similar threads on other forums.

Thanks

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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