BookmarkSubscribeRSS Feed
yawen929
Fluorite | Level 6

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;

 

5 REPLIES 5
Kurt_Bremser
Super User

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;
yawen929
Fluorite | Level 6

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

Tom
Super User Tom
Super User

The macro processor ignores strings that use single quotes instead of double quotes on the outside.

yawen929
Fluorite | Level 6

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 

Tom
Super User Tom
Super User
It means that the computer where SAS is running does not have that command. It could possibly have it, but not in any of the directories that the your process is using the look for programs to run. If so you might just need to spell out the full path to the zip command. But a number of people have started using 7-Zip instead. Perhaps you could switch to using that command instead. Check with the admins of the machine where SAS is running what commands they support for working with ZIP files.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 5 replies
  • 1291 views
  • 1 like
  • 3 in conversation