For these kind of situations in SAS, instead of trying to make a matrix with arrays, I usually go with some form of a function. To make your variable names you can just use &i or &load_dt. You will have to tinker with this because I do not have the data but I would go about it this way, calling a function like this (Looks more complicated than it is): %let dob = JAN2010; %put &dob.; %macro date_loop(StartMonYY=, Start=1, Stop=, Factor=1, Direction=+); %do i=&start %to &stop %by 1; %let SnapDate=%sysfunc(intnx(month,"01&StartMonYY"d,&Direction(&i-1)*&factor,end),date9.); %put Date for processing=&SnapDate; /*Different Formats*/ %let MonYY = %sysfunc(intnx(month,"&SnapDate"d,0,E),monyy7.); %put Month and Year = &MonYY; %let load_dt = %sysfunc(intnx(month,"&SnapDate"d,0,E),yymmn6.); %put Year and Month = &load_dt; /*For Testing*/ %let approx_days = %eval(&i.*30); %put Dob Pregnancy &approx_days; %let approx_lost = %eval(180 - (&i.*30)); %if %eval(&approx_lost.< 0) %then %do; %put Approx Lost GT 180 days; %end; %else %do; %put 180 days minus Approx Lost = &approx_lost.; %end; %end; %mend; %date_loop(StartMonYY=&dob.,Start=1,Stop=55,Factor=1,Direction=+);
... View more