Hi every one.
Now I have dataset A:
Date | AZ | WM | TG |
1/1/2015 | 20 | 30 | 50 |
1/2/2015 | * | * | * |
1/3/2015 | * | * | * |
1/4/2015 | * | * | * |
1/5/2015 | * | * | * |
1/6/2015 | * | * | * |
1/7/2015 | * | * | * |
1/8/2015 | * | * | * |
Now I have dataset B:
Date | AZ | WM | TG |
1/1/2015 | 10 | 0 | 12 |
I want dataset A look like:
Date | AZ | WM | TG |
1/1/2015 | 10 | 0 | 12 |
1/2/2015 | * | * | * |
1/3/2015 | * | * | * |
1/4/2015 | * | * | * |
1/5/2015 | * | * | * |
1/6/2015 | * | * | * |
1/7/2015 | * | * | * |
1/8/2015 | * | * | * |
Any suggestions?
proc sql;
update dataset_a t1
set
az=(select az from dataset_b where date=t1.date),
wm=(select wm from dataset_b where date=t1.date),
tg = (select tg from dataset_b where date=t1.date)
where exists (select * from dataset_b where date=t1.date);
quit;
proc sql;
update dataset_a t1
set
az=(select az from dataset_b where date=t1.date),
wm=(select wm from dataset_b where date=t1.date),
tg = (select tg from dataset_b where date=t1.date)
where exists (select * from dataset_b where date=t1.date);
quit;
thanks but looks some error
Never mind, I forgot to delete comma.
Not sure why people insist on putting commas at the end of the line instead of the beginning. They are much harder to see out there.
Since you already have a index variable DATE, why not use MERGE statement.
data want; merge A B; by date; run;
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.
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.