Hello, I followed this guide to create ZIP files of SAS datasets, but it messes with the timestamps and capitalizes all original file names. Is there a way to make it so the timestamps and file names aren't changed? Please find the sample code below. Thank you!
ods package (EXAMPLE) open nopf;
%macro zip();
%do i = 1 %to &cnt;
%let dataset = %scan(&list, &i);
ods package (EXAMPLE) add file="&datafolder.\&dataset..sas7bdat";
%end;
%mend zip;
%zip
ods package (EXAMPLE) publish archive
properties(archive_name="&zipname..zip" archive_path="&outpath.");
ods package (EXAMPLE) close;
There must be something happening with your macro code, as this works and gives me a .zip with lowercase filename:
ods package (EXAMPLE) open nopf;
ods package (EXAMPLE) add file="$HOME/sascommunity/have.sas7bdat";
ods package (EXAMPLE) publish archive
properties(archive_name="test.zip" archive_path="$HOME/sascommunity");
ods package (EXAMPLE) close;
Or it's Windows.
But yes, the timestamps are update to the current time.
Using the on-board zip supplied by AIX kept the timestamp:
filename oscmd pipe 'zip $HOME/sascommunity/have.sas7bdat.zip $HOME/sascommunity/have.sas7bdat 2>&1';
data _null_;
infile oscmd;
input;
put _infile_;
run;
Hello Kurt,
I am using the following code for retaining timestamps but it isn't working quite right:
filename oscmd pipe 'zip &outpath./&zipname..zip &datafolder./have.sas7bdat 2>&1'; data _null_; infile oscmd; input; put _infile_; run;
Is the issue with macro variables? Thank you!
Best,
Yawen
The macro processor ignores strings that use single quotes instead of double quotes on the outside.
Hello Tom,
A beginner error, thanks for catching it! I don't know if you might know the answer to this question, but now I am getting a new error message:
'zip' is not recognized as an internal or external command, operable program or batch file.
Can you please advise? Thank you!
Best,
Yawen
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.