BookmarkSubscribeRSS Feed
doqkxl
Fluorite | Level 6

Hi I am creating a process to zipping sas datasets and ran into an error where dataset name is the same and thus duplicate entry error.  Below is the code snippet.  For example I have a dataset MD_names in both folders "wk200901" and "wk200908".  The zipping had an error "zip entry duplicate name".

 

I was going to rename the dataset before the zipping, and name back if I decide to unzip.   I hope not to re-program this. 

 
 

ods package(archived) open nopf;

%do i=1 %to &tot_files;

ods package(archived) add file=&&file&i;

%end;

 

ods package(archived) publish archive properties (archive_name="&sysuserid._zip&sysdate._&systime..zip"

archive_path="&file_dir.");

ods package(archived) close;

 

4 REPLIES 4
jimbarbour
Meteorite | Level 14

In regular WinZip, there's an option to preserve sub-directories internally within the Zip archive, and therefore you could have duplicate file names and not need to manually rename files.  I believe ODS zip can do the same thing, and if so that might be a better option than manual renames.

 

@ChrisHemedinger lists a path in the last code snippet in this post:  https://blogs.sas.com/content/sasdummy/2014/01/28/create-zip-ods-package/.

 

Jim

Tom
Super User Tom
Super User

Looks like you are using macro language to generate code.

%do i=1 %to &tot_files;
  ods package(archived) add file=&&file&i;
%end;

So we can't tell what code you actually ran from just the program.  Please try running the steps without macro logic/macro variables and see if you still have issues.

ods package(archived) add file="wk200901/md_names.sas7bdat";
ods package(archived) add file="wk200908/md_names.sas7bdat";
doqkxl
Fluorite | Level 6

Thank you Tom for taking the time and responding to my post.  I tested again with hard coded in sas dataset names, which is the same.  I got the same error.  I am going to rename the dataset name to zip, and name it back when unzipping. 

 

I do not have the right version SAS 9.4M5 yet. 

doqkxl
Fluorite | Level 6

Thank you to those who replied to my question.  I ended up renaming the datasets before using the ODS zip.  It worked out ok.  I shall revisit this when my SAS version is upgraded to SAS9.4M5. 

dup_rename.PNG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1455 views
  • 2 likes
  • 3 in conversation