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

1.3k Views Asked by At

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.

1

There are 1 best solutions below

2
On

Running server side pipes requires the SAS server to be running with system option XCMD active. Are you seeing errors or other messages in the log? What is the output from PROC OPTIONS?

The SAS code as-is will log anything that the unzip command writes to standard out.

Unzip command -d option tells where to write extracted files. https://linux.die.net/man/1/unzip

The man page explains how to extract specific items from a zip.

"Synopsis

unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...] [-x xfile(s) ...] [-d exdir] "

The -p option extracts a zips file contents to stdout, which in turn would be read by your program.