BookmarkSubscribeRSS Feed
pessi
Obsidian | Level 7

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.

 

 

8 REPLIES 8
PGStats
Opal | Level 21

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
Reeza
Super User

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-...

 

 

pessi
Obsidian | Level 7

So just unzipping is not possible.

Reeza
Super User

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. 

Kurt_Bremser
Super User

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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).

pessi
Obsidian | Level 7

Hey RW9,

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

for zipping wzzip.exe

 

Reeza
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 8 replies
  • 3972 views
  • 1 like
  • 5 in conversation