04-22-2014 12:08 PM
I have a problem with data sets merging and date. I'd like to merge two dataset by date, merging with the closest date if needed. Here is an example:
I would like to get this dataset, by merging Dataset 1 and Dataset 2 (critical point is on the 15/03/2003 date value):
Date Y1 Y2
12/03/2003 1 10
15/03/2003 2 20
20/03/2003 3 30
Is there a way to do it automatically via SAS enterprise guide (via the join table button in query builder box) or do I need to write my own script for that?
Can you help me about the script too?
Thanks everyone for your help!
04-22-2014 12:30 PM
You can use EG point and click for this, the trick is know what query you need.
So perhaps first sketch the SQL query and then build it after?
It will go something like the following (untested)
create table want as
select a.date, a.y1, b.y2
from table1 as a
join table2 as b
group by a.date