Within a macro statement that identifies all excel files in a directory location, I'm looking to declare a libname statement for each file name so that i can pull in all sheets within each excel file. %macro fileinput(); %local i; %do i= 1 %to &nfile; /* Store import path and output filename into macro variables*/ data _null_; set files(firstobs= &i obs= &i); /* The length of fpath can't be over 201 since windows limitation */ call symput('fpath', "&indir" || filename); call symput('farch', "&indir.&outARCH."); call symput('foutname', tranwrd(strip(file), ' ', '_')); run; %PUT &fpath; %PUT &foutname; %put &farch; /* Declare File for import AND libname*/ FILENAME MCC_FILE "&fpath"; libname x excel "&fpath"; /* create a table with a variable for sheetnames*/ proc sql noprint; create table sheet as select memname from dictionary.members where libname='X' ; quit; /* Excel file import*/ %end; %mend; Until my client started putting multiple sheets in one file i used the Filename statement to pull import each separate excel file. I think this will no longer be needed after i create the libname method. However, when declaring the libname using libname x excel "&fpath"; Within the Macro statement i get this error: ERROR: Error in the LIBNAME statement. However if i change the statement to a hard coded path: libname x excel "\\wilmingtonfs.corp.ad.aaamidatlantic.com\share\databasemarketing\Media Campaign\2019 Initiative\Phone Calls\MCC\MCC-TCC Call1_18 thru 12_18.xlsx"; then the program works just fine creating a table with the different sheet names within the document. However, the document names will change each time so i have a dynamic process that pulls in the files and creates the path in a macro variable to handle such an instance. Can i create a libname within a macro statement using a macro variable path? Thanks
... View more