I think its easier to create the macro variable such that it includes the TO_DATE() as well. Then you can use use the variable plainly as
data work.dbdate;
format
dbvalue1 date9.
dbvalue2 date9.;
input dbvalue1:date9. dbvalue2:date9.;
cards;
30nov2010 31dec2010
run;
data _null_;
set work.dbdate;
call symput('DAY1',"TO_DATE('"||PUT(DBVALUE1,YYMMDDN8.)||"','YYYYMMDD')");
call symput('DAY2',"TO_DATE('"||PUT(DBVALUE2,YYMMDDN8.)||"','YYYYMMDD')");
RUN;
proc sql;
connect to oracle as db(xxxxxxxxxxxxx);
create table tst as select * from connection to db (
select * from mdm.dbdates
where date_value between &day1 and &day2
);
disconnect from db;
quit;
The oracle prepared statement is:
select * from mdm.dbdates where date_value between TO_DATE('20101130','YYYYMMDD') and TO_DATE('20101231','YYYYMMDD')
... View more