BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nickspencer
Obsidian | Level 7
Hello all,
I have a master dataset with few hundred columns including columns ID, x ,y and status. I have another dataset table2 that also has columns ID and status2.
I want to update the column values of x and y on master dataset based on criteria that involves both master and table2 datasets. I am doing this in teradata sql right now.

Update a
From master a, table2 b
set x=1,y=1
where a.status=‘Inactive’
and b.status2=‘Active’

Can I do the same update with sas datasets?
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Standard ANSI SQL does this. For example:

data MASTER; A=0; X=0; Y=0; STATUS='Inactive' ;
data TABLE2; A=0; STATUS2='Active';
run;
proc sql;
  update MASTER
  set X=1,Y=1
  where A in (select unique A from TABLE2 where STATUS2='Active')
    and STATUS='Inactive';  

 

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

I don't see any join criteria here.How is table b used?

nickspencer
Obsidian | Level 7
Chrisnz I missed the join condition on the query. Here is the complete query.
Update a
From master a, table2 b
set x=1,y=1
where a.ID=b.ID
and a.status=‘Inactive’
and b.status2=‘Active’
nickspencer
Obsidian | Level 7
@Kurt_Bremser
I does not have to be a teradata table. I need the output as a sas dataset.
ChrisNZ
Tourmaline | Level 20

Standard ANSI SQL does this. For example:

data MASTER; A=0; X=0; Y=0; STATUS='Inactive' ;
data TABLE2; A=0; STATUS2='Active';
run;
proc sql;
  update MASTER
  set X=1,Y=1
  where A in (select unique A from TABLE2 where STATUS2='Active')
    and STATUS='Inactive';  

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2121 views
  • 0 likes
  • 3 in conversation