Macro to automate selection of multiple files with similar name
Macro to automate selection of multiple files with similar name
(OP)
data lib.p_claim2;
set
p_claim.file06_2001_2
p_claim.file06_2001_3
p_claim.file06_2001_4
p_claim.file06_2001_5
p_claim.file06_2001_6
p_claim.file06_2001_7 ;
run;
is there a way with a macro that I can reference these p_claim.files without having to spell out each and every full name of the file? I can have up to twenty of these at a time.
set
p_claim.file06_2001_2
p_claim.file06_2001_3
p_claim.file06_2001_4
p_claim.file06_2001_5
p_claim.file06_2001_6
p_claim.file06_2001_7 ;
run;
is there a way with a macro that I can reference these p_claim.files without having to spell out each and every full name of the file? I can have up to twenty of these at a time.
RE: Macro to automate selection of multiple files with similar name
%macro overall;
data setted;
set
%do i = 1 %to 7; /*where 1 is the first number and 7 is the last*/
p_claim.file06_2001_&i
%end;
;
run;
%mend;
%overall;
RE: Macro to automate selection of multiple files with similar name
p_claim.file06_2001_1
p_claim.file06_2001_2
p_claim.file06_2001_3
p_claim.file06_2002_1
p_claim.file06_2002_2
p_claim.file06_2002_3
would I just use just use a separate macro for each year scenario?
/*year 2001*/
data mylib.Files;
set %do i = 1%to 3;
mylib.p_claim.file06_2001_&i
%end;
;
run;
%mend;
%overall;
/*year 2002*/
data mylib.Files;
set %do i = 1%to 3;
mylib.p_claim.file06_2002_&i
%end;
;
run;
%mend;
%overall;
RE: Macro to automate selection of multiple files with similar name
CODE
%macro overall (lib=p_claim, file=file06, year=, maxfile=);
data setted&YEAR.;
set
%do i = 1 %to &MAXFILE.;
&LIB..&FILE._&YEAR._&I.
%end;
;
run;
%mend;
%*-- use the macro. ;
%overall (year=2001, maxfile=3);
%overall (year=2002, maxfile=3);
%*-- use the macro and override a default. ;
%overall (file=fileABC, year=2003, maxfile=7);