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

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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