Skip to content

Instantly share code, notes, and snippets.

@statgeek
Last active April 4, 2023 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/9602105 to your computer and use it in GitHub Desktop.
Save statgeek/9602105 to your computer and use it in GitHub Desktop.
SAS - Zip Files using 7Zip
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;
@fxie4wk
Copy link

fxie4wk commented Apr 4, 2023

How to unzip .7z. I try to do so by change a to e, but not work. Thanks1

@statgeek
Copy link
Author

statgeek commented Apr 4, 2023

@fxie4wk change -tzip to -t7z or try removing it entirely. The -tzip specifies that the file type is zip.

@fxie4wk
Copy link

fxie4wk commented Apr 4, 2023

neither works. all just archive/zip again

@statgeek
Copy link
Author

statgeek commented Apr 4, 2023

Post the issue on communities.sas.com with the full code you're using and I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment