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';  

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2572 views
  • 0 likes
  • 3 in conversation