Yes. I suppose there is unique id in temp1.
If you have duplicate ids ,then sql 's Cartesian Product is good choice.
[pre]
data temp1;
infile datalines dlm=' ,';
input id $ StartDate : date9. Value;
format StartDate date9.;
datalines;
001,01JUL2010, 6050
001,01OCT2009, 6050
002,27MAY2010, 9050
003, 11DEC2010, 16500
;
run;
data temp2;
infile datalines dlm=' ,';
input id $ StartDate : date9. EndDate : date9. OtherValue;
datalines;
001, 01SEP2009,17DEC2009, 7500
001, 18DEC2009,29APR2010, 7000
001, 30APR2010,31DEC2010, 6000
002, 10MAY2010,16AUG2010, 11000
002, 17AUG2010,26NOV2010,10500
002, 27NOV2010,11APR2011,9500
002, 12APR2011,31DEC2010,9000
003, 01DEC2010,12JAN2011,20000
003, 13JAN2011, 25MAY2011,19500
003, 26MAY2011, 31DEC9999, 18990
;
run;
proc sql;
create table want as
select a.id as id,b.startdate as startdate,value,othervalue
from temp2 as a,temp1 as b
where a.id = b.id and b.startdate between a.startdate and a.enddate
;
quit;
[/pre]
Ksharp
... View more