DATA Step, Macro, Functions and more

How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Unix

Reply
New Contributor
Posts: 3

How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Unix

[ Edited ]

Hi All,

 

I want to extract SAS datasets from a Zip file using SAS unix. I want to save these extracted datasets to a particular directory.

 

And if Zip file is password protected then how to extract SAS datsets from Zip file to a specified directory in SAS UNIX environment. 

 

I am doing this to have automation in my code. Need help.

 

Thank you.

Super User
Posts: 17,840

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

Can you use X commands?

New Contributor
Posts: 3

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

I can use X commands but i dont know how to use it in SAS (Unix environment).

If you have any solution it will be great.

 

Thank you

Super User
Super User
Posts: 7,401

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

I generally don't recommend just automating an extract.  To do things safely you should have a full process of handling the data, from where to save the zip, how to unpack, how to validate everything worked, how to validate the data against the import specification etc.  Just unpacking a zip doesn't provide much information of the process.

New Contributor
Posts: 3

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

Thanks for your inputs sir.

 

But i have a requirement like this and need to complete this. 

e.g. If Zip file is saved on "C:\input\DS.zip" which contains Datasets then i wanted these datasets to be extracted at  "C:\output" folder.

I am able to do this on my windows PC using X command. but i have this requirement in UNIX. So i am not at all hands on UNIX. So doesnt know how to use X command in Unix.

 

Following code i have used to extract datasets in windows environment:

%LET PASS = Abc123;

x unzip -o -P &PASS "C:\input\DS.zip" -d "C:\output";

 

If you have any method to do the same in Unix environment. it will be great Smiley Happy thank you so much.

Super User
Posts: 17,840

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

You should be able to google the relevant commands for UNIX. 

 

http://www.cyberciti.biz/faq/linux-howto-unzip-files-in-root-directory/

 

I would first find the relevant command on my UNIX box and then implement it in SAS. 

Super User
Super User
Posts: 7,401

Re: How to unzip a zip file and extract SAS datasets from zip file to another directory using SAS Un

Well, I return to my post above, its is about the process, not coding.  You need to create a workable, validatable, and reproduceable process for the import of data.  You say if a file <xyz> contains <data> then <do>.  That is a process.  First you need a method of securely and surely recieving said file.  How will you do that in a consitent manner over the lifetime of the process?  Now what the file contains - what does data mean, XPT files, CSV, datasets etc., could be all number of things, where is the data import agreement which details what is contained, and some sort of spec to validate it against.  Then the <do> part is to publish it to production for others to use.

 

Of course, if you want to save yourself the trouble just do it manually.

Ask a Question
Discussion stats
  • 6 replies
  • 1093 views
  • 0 likes
  • 3 in conversation