BookmarkSubscribeRSS Feed
avz645
Calcite | Level 5

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.

6 REPLIES 6
avz645
Calcite | Level 5

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

avz645
Calcite | Level 5

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 🙂 thank you so much.

Reeza
Super User

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. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 6 replies
  • 6427 views
  • 0 likes
  • 3 in conversation