How to unzip a file via SAS (via SAS Studio / SSOD)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

How to unzip a file via SAS (via SAS Studio / SSOD)

I'm trying to decompress a file in the zip format using pure SAS code, that I can integrate as one of the steps of a SAS script. I'm running SAS via the web version of SAS Studio on the cloud hosted version (SSOD).

 

Reading the documentation, I was able to come up with this, which attempts to expand all files in the zip to the same directory: 

 

data _null_;
  infile "unzip /project/input/file.zip" pipe ;
  input ;
  put _infile_;
run;

But I couldn't find how to tell it a specific directory to write the files, and I couldn't find how I extract a specific file from the zip file.


Accepted Solutions
Solution
‎05-12-2018 03:50 PM
Community Manager
Posts: 3,440

Re: How to unzip a file via SAS (via SAS Studio / SSOD)

If using a hosted SAS, you might not have the unzip command (OS shell) as an option.  But you can use the FILENAME ZIP method to list and read files.

View solution in original post


All Replies
Super User
Posts: 10,278

Re: How to unzip a file via SAS (via SAS Studio / SSOD)

You could first extract a list of files, and then extract all files one-by-one to stdout, all by using filename pipe.

See the documentation of unzip: https://linux.die.net/man/1/unzip 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎05-12-2018 03:50 PM
Community Manager
Posts: 3,440

Re: How to unzip a file via SAS (via SAS Studio / SSOD)

If using a hosted SAS, you might not have the unzip command (OS shell) as an option.  But you can use the FILENAME ZIP method to list and read files.

Occasional Contributor
Posts: 17

Re: How to unzip a file via SAS (via SAS Studio / SSOD)

Posted in reply to ChrisHemedinger

That works! Thank you

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 138 views
  • 1 like
  • 3 in conversation