how to join two datasets and update one column values only not affects other columns in sas?

311 views Asked by At

this is a sample datasets need to be update one columns only .same columns name but different values add only like age in first ds. data step or proc sql; common values dob and name Please help me thanks first data set

data sql;
 input name $4. age 2. dob 8. address $5.;
datalines;
john  94 kkdi
john  88 pdk
john  93 cbe
;
run;

second dataset

data sql;
 input name $7. age 2. dob 8. address $5.;
datalines;
john 1 94 mmm
john 0 88 xxx
laya 1 93 yyy
;
run;
output:
john 1 94 kkdi
john 0 88 pdk
laya 1 93 cbe
1

There are 1 answers

0
LuizZ On BEST ANSWER

I am not sure if I got your question. But comparing the two datasets and the desired output, it seems that "dob" variable is your id, and you want to get the address from the first table into the second one.

So, what you need is:

proc sql;
create table new_data as
select
t2.name, 
t2.age,
t2.dob,
t1.address 
from dataset_2 as t2
left join dataset_1 as t1 on t2.dob=t1.dob;
quit;

Best,