DATA Step, Macro, Functions and more

Unzipping a file in windows sas. Is it possible?

Reply
New Contributor
Posts: 3

Unzipping a file in windows sas. Is it possible?

I want to unzip a file in windows sas. Is it possible?
abc_clinc_20160204123456.gz

File might be txt,csv,.dat anything.
output should be like abc_clinc_20160204123456.txt/csv/dat

 

I tried using below commands. but unable to do.

x  "gunzip \path\abc_clinc_20160204123456.gz";

%sysexec gunzip "\path\abc_clinc_20160204123456.gz";

 

I don't want to use unix.

 

 

Respected Advisor
Posts: 4,919

Re: Unzipping a file in windows sas. Is it possible?

Attach an example .gz file, if at all possible. Anybody who succeeds to unzip it in Windows SAS can tell you how he/she did it.

PG
Super User
Posts: 19,770

Re: Unzipping a file in windows sas. Is it possible?

You have a few options. 

 

1. If you have SAS 9.4 and want to read from file you don't need to unzip file. 

2. Use OS/Windows command to use win zip or 7zip to zip/unzip file. 

 

Here re how to zip files using SAS and 7zip. 

https://gist.github.com/statgeek/9602105

 

SAS blog on file name ZIP method

http://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-...

 

 

New Contributor
Posts: 3

Re: Unzipping a file in windows sas. Is it possible?

So just unzipping is not possible.

Super User
Posts: 19,770

Re: Unzipping a file in windows sas. Is it possible?

Yes it is. 

The example above zips, but you could similarily unzip if you found the correct OS command. Assuming your allowed to pass OS commands. If you're not, then no, you can't unzip. 

Super User
Posts: 7,762

Re: Unzipping a file in windows sas. Is it possible?

All the programs that can do a zip from the commandline also have options to unzip. Just find the correct option in the documentation for your zipping utility.

A quick compendium of the commandline utility for the 7zip package can be found here: http://www.dotnetperls.com/7-zip-examples

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,942

Re: Unzipping a file in windows sas. Is it possible?

Can I ask what you mean by this line:

"I don't want to use unix."

 

Is your SAS installed on Windows or Unix?  If you are on Windows, then you don't need to use Unix, simply put Winzip or your favourite unzip package on your machine, then ue X command to pass through to the OS the necessary string to run it - assumes Winzip is installed to C:\Winzip:

X ' "c:\Winzip\Winzip.exe" "<path to your file><filename>.zip" "<path to output location>"';

This calls the program in Winzip with the two parameters file and output location.  If your installed on Unix, then you need to use a Unix equivalent.  SAS does not provide Third Party unpack tools (as yet anyways).

New Contributor
Posts: 3

Re: Unzipping a file in windows sas. Is it possible?

Hey RW9,

Thanks. But for unzipping there is seperate exe file wzunzip.exe.

for zipping wzzip.exe

 

Super User
Posts: 19,770

Re: Unzipping a file in windows sas. Is it possible?

@pessi It depends, you can use various applications so the exact command can vary.

Ask a Question
Discussion stats
  • 8 replies
  • 948 views
  • 1 like
  • 5 in conversation