So, let me get this straight. Each folder has a SAS member in it, or does it have a flat file in it? If the latter, you need an infile statement that you can programmatically change using the FILEVAR (or is it FILENAME) option of the INFILE statement. Otherwise, is the SAS member always consistent between the various folders, and how many years and months do you need to read.
Here are two possible solutions for the latter:
%macro spin1;
data test;
set
%do year=2009 %to 2010;
%do month = 1 %to 12;
%let zmonth = %sysfunc(putn(&month,z2.));
"C:\&year\&zmonth\raw.sas7bdat"
%end;
%end;
;
run;
%mend spin1;
%spin2;
%macro spin2;
%let libref=0;
%do year=2009 %to 2010;
%do month = 1 %to 12;
%let zmonth = %sysfunc(putn(&month,z2.));
%let libref = %eval(&libref+1);
libname LIBNAM&libref "C:\&year\&zmonth";
%end;
%end;
%let maxlibref = &libref;
DATA TEST;
SET
%do i=1 %to &maxlibref;
LIBNAM&i..RAW
%end;
;
run;
%do i=1 %to &maxlibref;
LIBNAME LIBNAM&libref clear;
%end;
%mend spin2;
%spin2;
... View more