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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.