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
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.
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.
OK, I reached the same conclusion by searching similar threads on other forums.
Thanks
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.