Hello, I am trying to automate program that pull data from Oracle in certain period of time, but I keep getting error. Could you please help me to see how to fix this. Thank you. %macro setup; data temp; TODAY = TODAY(); nextday = INTNX('MONTH',TODAY,3); CURQ = QTR(today); format today nextday date9.; if CURQ = 1 then do; /**** reporting current year ***/ adm_cur_frm = put(intnx('year',today, -1), mmddyy10.); adm_cur_to = put(intnx('year',today, -1,'end'), mmddyy10.); end; else do; /**** reporting current year ***/ adm_cur_frm = put(intnx('year',today, 0), mmddyy10.); adm_cur_to = put(intnx('Qtr',nextday, 0,'end'), mmddyy10.); end; CALL SYMPUTX('adm_cur_frm',adm_cur_frm); CALL SYMPUTX('adm_cur_to',adm_cur_to); RUN; %put &adm_cur_frm; %put &adm_cur_to; %mend; %setup; libname lib1 oracle schema='&schema' defer=yes path=&path user=&user pw="&pw"; %macro get(period=); proc sql; create table test as select * from lib1.chrg_itm where adm_dt between to_date("&&adm_&period._frm.","mm/dd/yyyy") and to_date("&&adm_&period._to.","mm/dd/yyyy") ; quit; %mend; %get(period=cur); ERROR: Function TO_DATE could not be located. ERROR: Function TO_DATE could not be located. ERROR: Expression using BETWEEN has components that are of different data types. The data type of 'adm_dt' is below. Type Len Format Informat Num 8 DATETIME20. DATETIME20. I also tried the following, but the program just keep running, I have to force SAS to kill the program. where adm_dt between &&adm_&period._frm and &&adm_&period._to Another one I tried below, I got zero record back, but I know there are records in between this period, can't be zero. where pstng_dt between input(strip("&&adm_&period._frm."),mmddyy10.) and input(strip("&&adm_&period._to."),mmddyy10.) Any suggestion will be helpful. Thanks
... View more