Hello All,
I need to gzip large sas dataset and copy it from one folder to another
Location of sas tables in windows sas
\\10.00.112.12\ddbg_va\Data\Backup SAS Data\Final Tables\currentmonth.sas7bdat
The location is mentioned above. However our sas is on windows, and I am unable to gunzip it and tried various commands but could not do it.
filename source \\10.00.112.12\ddbg_va\Data\Backup SAS Data\Final Tables\currentmonth.sas7bdat";
filename tozip zip "\\10.00.112.12\ddbg_va\Data\Backup SAS Data\Final Tables\currentmonth.sas7bdat.gz" GZIP;
data _null_;
infile source;
file tozip;
input;
put _infile_;
run;
I got an error for GZIP statement. I have also tried x gzip -c and below method to be unsuccessful in doing so
systask command "gzip '\\10.00.112.12\ddbg_va\Data\Backup SAS Data\Final Tables\currentmonth.sas7bdat"
wait taskname=zip status= check shell;
GZIP was added in SAS 9.4 Maintenance 5. See details here.
If you don't have the M5 level, and you need GZ files, then you'll have to use an external tool. On Windows though, you'll have to first install a tool like gzip or 7-zip that can support gz files.
I have 7 zip installed in my windows.. but when i run the code, it is showing error or sometimes gzip happens with 0 kb size
1. Test your command line string in the command window first to make sure it's zipped
2. Then use CALL SYSTEM or %SYSEXEC or X command to call the commandline.
Here's how I call it:
options noxwait noxsync;
data _null_;
*Path to winzip program;
zipexe='"C:\Program Files\7-Zip\7z.exe" a -tzip';
*Zip file name;
zipfile="C:\My Documents\Sample.zip";
*File to be zipped;
file="C:\Temp\Sample.txt";
*Full cmd line to be passed to command line. It embeds the quotes for paths with spaces;
cmd = zipexe ||' "'|| zipfile ||'" "'|| file ||'"' ;
*Place note in log;
putlog "NOTE-Processing command" cmd;
*Execute command;
call system(cmd);
run;
https://gist.github.com/statgeek/9602105
If you still have issues, post your full code and log.
@sameer112217 wrote:
I have 7 zip installed in my windows.. but when i run the code, it is showing error or sometimes gzip happens with 0 kb size
I prefer the following method for running external commands, not only for debugging, but also in production:
filename oscmd pipe "the command you want to run 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
filename oscmd clear;
The 2>&1 at the end will redirect all error output to the pipe, so you will find all responses in your SAS log.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.