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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.