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

Hi,

 

I would like to learn how to update a target table with values from another table. There are about 1000 variables in the target table and only about 350 variables (chat or num variables) need to be updated from a renew dataset. The rules are

 

  1. If the renew dataset has value in the variables then use that value in the target dataset.
  2. If the renew dataset has missing value then keep the value in the target dataset.
  3. If both target and renew datasets have missing value then keep the value as missing. 

 

I have generated a very simple example.

 

data target;
input id1$ id2 a b c$ d$ e f;
datalines;
1 10 6 8 x1 x2 9 3
2 20 5 . y1 . 6 .
;
run;

 

data renew;
input id1$ id2 a b c$ d$ e f;
datalines;
1 . 6 8 x10 . 9 30
2 20 . 3 . y20 6 .
;
run;

 

the data want will be

id1

id2

a

b

c

d

e

f

1

10

6

8

x10

x2

9

30

2

20

5

3

y1

y20

6

.

 

Thank you so much.

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11
data target;
	update target renew;
	by id1;
run;

 

Update Statement will meet your requirements :

 

1. It Does not update the value in the master by default, if the transaction table has missing values.

2. Sets to missing if both master and transaction have missing values

 

View solution in original post

1 REPLY 1
r_behata
Barite | Level 11
data target;
	update target renew;
	by id1;
run;

 

Update Statement will meet your requirements :

 

1. It Does not update the value in the master by default, if the transaction table has missing values.

2. Sets to missing if both master and transaction have missing values

 

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 824 views
  • 1 like
  • 2 in conversation