Hello SAS community, I am having troubles importing excel files from my directory. I have build a macro that loops through the directory to import the excel files. However, the titles are inconsistent and some titles are providing a error. Example of excel files in the directory: APPLES_10-09-2018_REVENUE.xlxs APPLES_01_01_2017_REVENUE.xlxs APPLES_10_01_2017_REVENUE.xlxs APPLES_05-06-2017_REVENUE.xlxs APPLES_03-10-2018_(REVENUE).xlxs In this case the - and ( ) characters are giving me a hard time to import them. Is it possible to write a code in SAS that can change all - characters of the excel titles to _ and remove ( ) characters ? How will that code sort of look like? your expertise is much welcome 🙂 The Log + ERROR STATEMENT: ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name. 75 /* This macro imports all files of type1 specified in the folder and save them as datasets */ 76 %macro import_loop1; 77 %do i=1 %to &Total; 78 proc import datafile= "&filenm./&&File&i" 79 out= work.&&name&i 80 dbms=XLSX 81 replace; 82 Sheet=&type1sheet; 83 getnames=yes; 84 datarow=2; 85 run; 86 87 %let source= &&name&i; 88 data work.&source; 89 set work.&source; 90 Sourcefile_get = SYMGET('source'); 91 Sourcefile = substr(Sourcefile_get, 2,(length (Sourcefile_get)-3)); 92 drop Sourcefile_get 93 run; 94 95 proc datasets; 96 append base=work.appended_&filetype1 data=work.&&name&i force; 97 run; 3 The SAS System 20:56 Wednesday, October 17, 2018 98 %end; 99 %mend import_loop1; 100 %import_loop1 ERROR: The value 'APPLE_INVOICE_01-07-2018_83274.XLS'n is not a valid SAS member name.
... View more