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.
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.
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
So just unzipping is not 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.
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
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).
Hey RW9,
Thanks. But for unzipping there is seperate exe file wzunzip.exe.
for zipping wzzip.exe
@pessi It depends, you can use various applications so the exact command can vary.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.