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;
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
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";
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.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.