Hi. I have a Filename Statement that I need to use a wildcard in (e.g. *). The first commented out Filename Statement works fine, but when I update the code to use the uncommented Filename Statement which includes the * wildcard the code errors out.
Any suggestions on how I can correct this issue? I'd appreciate any help. Thanks.
/*FILENAME Site "'C:\Users\SteveBuechler\Box Sync\IBM\USPS\In Scope Contracts For Site\Parsed Output_Erie 0330_1000.xlsx'";*/
FILENAME Site "'C:\Users\SteveBuechler\Box Sync\IBM\USPS\In Scope Contracts For Site\Parsed Output_Erie*.xlsx'";
PROC IMPORT OUT= Sites&site DATAFILE= Site
DBMS=XLSX REPLACE;
SHEET="Trips";
GETNAMES=YES;
RUN;
ERROR: Physical file does not exist, C:\\U.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
Perhaps it is just that PROC IMPORT doesn't get it.
Try finding the filename yourself first.
data _null_;
length fname $256 ;
infile "C:\Users\SteveBuechler\Box Sync\IBM\USPS\In Scope Contracts For Site\Parsed Output_Erie*.xlsx"
obs=1 filename=fname
;
input;
call symputx('fname',fname);
run;
PROC IMPORT OUT= Sites&site DATAFILE= "&fname"
DBMS=XLSX REPLACE
;
SHEET="Trips";
GETNAMES=YES;
RUN;
HI @buechler66 May I ask the reason you are having quotes within quotes?
Though I don't think that causes errors, but just asking. I would have thought the syntax is rather convenient to have
FILENAME Site "C:\Users\SteveBuechler\Box Sync\IBM\USPS\In Scope Contracts For Site\Parsed Output_Erie*.xlsx";
Perhaps it is just that PROC IMPORT doesn't get it.
Try finding the filename yourself first.
data _null_;
length fname $256 ;
infile "C:\Users\SteveBuechler\Box Sync\IBM\USPS\In Scope Contracts For Site\Parsed Output_Erie*.xlsx"
obs=1 filename=fname
;
input;
call symputx('fname',fname);
run;
PROC IMPORT OUT= Sites&site DATAFILE= "&fname"
DBMS=XLSX REPLACE
;
SHEET="Trips";
GETNAMES=YES;
RUN;
Is this a complete example? Typically you would not use a mix of double and single quotes in a filename as shown for a single input file.
And if your wildcard expansion results in two or more files then Proc Import isn't going to like it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.