Jaap has already given you answer:
call symputx('file'||put(_n_,8. -L ),filenames,'G');
saskiwi already made the remark you will get a problem at the 10-th value.
The issue is putting a numeric will add blanks or zero-s to get postions filled. An REXX stem or SAS macro array is based on numbers not being adjusted.
Correct the adjustment to follow sas-macro conventions. I think 10.000 files as limit will do (4 positions).
call symputx('file'||put(_n_,1.),filenames,'G');
TRIM(LEFT(PUT(_n_,4.))
The original code cannot import any .xls files and gives me the following error. All filenames are .xls with only letters, digits, and underscores:
316
317 data _null_;
318 set file;
319 call symputx('file'||put(_n_,1.),filenames,'G');
320 run;
ERROR: Symbolic variable name FILE* must contain only letters, digits, and underscores.
NOTE: Argument 1 to function SYMPUTX at line 319 column 6 is invalid.
filenames=M:\LS\Data\BannerMerge\FilesGrade350_201 _ERROR_=1 _N_=10
ERROR: Symbolic variable name FILE* must contain only letters, digits, and underscores.
NOTE: Argument 1 to function SYMPUTX at line 319 column 6 is invalid.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.