Hello! Still pretty new to SAS. I have a table of Check Dates that I need to compare my dataset to. The trick is, sometimes the dates refer to a hard coded Macro variable date, and sometimes they come in as MM/DD/YYYY. Was wondering if there is a magic wand to convert all dates to a single date format so i can do my compare. Hope that makes sense! Here's what I have. Everything works except the final proc sql's where, which is where I'm stuck. It's also probably not the most elegant solution, but it's where I'm at right now. DATA HAVE;
INPUT MEMBERID : $20. DOB : MMDDYY10.;
Format DOB MMDDYY10.;
CARDS;
1111 1/12/2001
2222 2/11/2003
3333 3/11/2003
4444 1/13/2000
;run;
DATA RANGE_CHECK;
INPUT Check_Number Low_DT : $50. High_DT : $50.;
CARDS;
1 3/1/2000 5/1/2001
2 &Hardcode_High_DT. &Hardcode_High_DT.
;run;
DATA FINAL_TABLE;
format Check_Number 8.;
format MEMBERID $20.;
format DOB MMDDYY10.;
;run;
%macro FindRanges();
%let Hardcode_Low_DT = 02JAN2002;
%let Hardcode_High_DT = 02DEC2003;
proc sql ;
SELECT Check_Number,
quote(strip(resolve(Low_DT))),
quote(strip(resolve(High_DT))) into
:Check_Number_List separated by ' ',
:Low_DT_List separated by ';',
:High_DT_List separated by ';'
FROM RANGE_CHECK;
%let Check_Count =&sqlobs;
;quit;
%do t = 1 %to &Check_Count.;
%let Check_Number_Value = %scan(&Check_Number_List, &t);
%let Low_Value = %scan(&Low_DT_List, &t, ';'); /* <- Probably Need to change this */
%let High_Value = %scan(&High_DT_List, &t, ';'); /* <- Probably Need to change this */
proc sql;
INSERT into FINAL_TABLE
SELECT &Check_Number_Value., MEMBERID, DOB
From HAVE
Where DOB between &LowValue. and &High_Value. /* <- DEFINITLY Need to change this! */
;quit;
%end;
%mend FindRanges;
%FindRanges(); What i'm hoping to have in the FINAL_TABLE would be: FINAL_TABLE
Check_Number MEMBERID DOB
1 1111 1/12/2001
2 2222 2/11/2003
2 3333 3/11/2003 Thanks so much!
... View more