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

Hello all

 

I've tried to create an import statement that reads in a zip file with a wildcard in the zipfile name, much like text and csv files

 

 

filename x zip ".....\%%%%%%%%-RestOfFileZipName.zip" member = "CSVToImport*.csv";



data fileout;
   infile x
   firstobs = 1 
   dsd dlm = ',' 
   truncover
   ;
      var1   :8.
      var2   :8.
      ;
run;

where I've put the "%" is where I expect to have the wildcard to import the zip, like I said I'd like it to work the same way the " * " wildcard works with the member. Has anyone done this before, can you advise if this is even possible.

 

Thanks in advance.

 

PS, using SAS 9.4

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You need to find the name in some other way.

Here is one way to find the first filename that matches your pattern and put it into a macro variable:

data _null_;
  length fname $256 ;
  infile "....\*-RestOfFileZipName.zip" filename=fname obs=1 ;
  input;
  call symputx('zipfile',fname);
run;  

then use the macro variable in your existing FILENAME statement.

filename x zip "&zipfile" member = "CSVToImport*.csv";

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

You need to find the name in some other way.

Here is one way to find the first filename that matches your pattern and put it into a macro variable:

data _null_;
  length fname $256 ;
  infile "....\*-RestOfFileZipName.zip" filename=fname obs=1 ;
  input;
  call symputx('zipfile',fname);
run;  

then use the macro variable in your existing FILENAME statement.

filename x zip "&zipfile" member = "CSVToImport*.csv";
Nahidul
Calcite | Level 5
Thanks Tom, that's exactly what I was looking for!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 550 views
  • 4 likes
  • 2 in conversation