SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mitchell_keener
Obsidian | Level 7

Hello, 

 

I am trying to extract text files that are saved within multiple zip files. For example, I need to extract a text file within a structure such as "C:\Users\myname\Documents\files.zip\specifictextfile.zip\mydata.txt". 

 

In my case, each text file is saved within their own zip file inside "files.zip". I have been able to successfully extract the text file within a single zip level, so something like  "C:\Users\myname\Documents\specifictextfile.zip\mydata.txt" but I cannot get it out of the two level zips. 

 

This resource was extremely helpful with extracting from a one level zip: https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in...

 

Even if I could just extract the second level zips into their own folder, I could use the code at the link above to extract the text files from there. Does anyone know if this is possible or have any ideas how to do this? I could resort to manually extracting the "files.zip" first then using sas to read the txt files within each "specifictextfile.zip" zip, but I would rather not if possible. Let me know if I can provide additional information to assist with my question. The only example code I have was the code used in the blog to extract from a single zip file so I did not bother including it. Thanks so much. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Nope.  Extract the embedded ZIP to a physical file, perhaps in your WORK directory.  Then you can extract the files from that ZIP file.  Repeat as many times as they have levels of nesting.

 

That is just a silly way to send data.

They should have just copied the files from the sub-files into the target ZIP as folders.  Storing a ZIP file in a ZIP file is just adding work for you without any added value.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Nope.  Extract the embedded ZIP to a physical file, perhaps in your WORK directory.  Then you can extract the files from that ZIP file.  Repeat as many times as they have levels of nesting.

 

That is just a silly way to send data.

They should have just copied the files from the sub-files into the target ZIP as folders.  Storing a ZIP file in a ZIP file is just adding work for you without any added value.

mitchell_keener
Obsidian | Level 7
Thanks for the reply. Much appreciated!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2 replies
  • 1927 views
  • 0 likes
  • 2 in conversation