Hi, I have tried to work out using Sample data. data sample; input dates mmddyy8. a b; format dates mmddyy10.; datalines; 01/01/09 1 5 01/11/09 2 2 01/21/09 4 6 01/31/09 2 3 02/10/09 5 7 02/20/09 7 1 03/02/09 3 5 03/02/10 8 2 03/03/10 2 7 03/13/10 8 3 03/23/10 3 7 04/2/10 5 2 04/12/10 3 7 04/12/11 5 4 04/22/11 4 5 05/02/11 6 2 05/12/11 2 7 05/22/11 7 6 06/01/11 4 8 06/11/11 5 3 06/21/11 8 3 ; proc sort data = sample; by dates; run; /* Finding Unique dates more than 01/01/2010 which have atleast one year of history data*/ data unique_dates; set sample (keep = dates); by dates ; if dates > = input("01/01/10" , mmddyy8.); if first.dates then output; run; /* Passing each date in the macro for finding correlation for that particular date based on data for last one year from that date*/ data _null_; set unique_dates; call symput("value",put(dates,mmddyy8.)); %macro_process(value); %put &value; run; %macro macro_process(value); data subset; set sample ; /* Subsetting Data for last one year from the particular date*/ if dates < = intnx('year',input("&value",mmddyy8. ),-1) then output; run; /*Running Correlation proc for particular date and relevant data*/ proc corr data = subset (drop = dates); run; %mend macro_subset(value); /*Each of the Correlation output can be saved in any form using ODS*/ Vishal
... View more