BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buechler66
Barite | Level 11

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

6 REPLIES 6
buechler66
Barite | Level 11
Note that using the wildcard I will be defining the same file, just without the Date Time portion of the name. Only one file will ever qualify even tho I'm using the * wildcard.
novinosrin
Tourmaline | Level 20

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";
buechler66
Barite | Level 11
No reason, I've just been trying various syntax to see if I can get the *
wildcard to work.
Tom
Super User Tom
Super User

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;
buechler66
Barite | Level 11
Works like a charms. Thanks for taking the time to help!
ballardw
Super User

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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 6661 views
  • 1 like
  • 4 in conversation