BookmarkSubscribeRSS Feed
Leo9
Quartz | Level 8

Hi All,

 

I am trying to read zip file which has lot of sas datasets. I want to extract all this sas datasets at once and placed them in a folder.

I am successful in reading the content of zip file but not sure how to extract sas datasets from this zip file and placed them in a different folder. Below is the code which reads content of zip file. 


filename inzip ZIP "x:\test.zip";

DATA FLS(KEEP=MEMNAME);
FILENAME inzip ZIP "x:\test.zip";
LENGTH MEMNAME $200;
FID=DOPEN("inzip");
IF FID=0 THEN
STOP;
MEMCOUNT=DNUM(FID);
DO I=1 TO MEMCOUNT;
MEMNAME=DREAD(FID,I);
OUTPUT;
END;
RC=DCLOSE(FID);
RUN;


proc print data = fls ;
run;

4 REPLIES 4
Reeza
Super User
If you google the topic with Chris Hemidinger name you'll find several fully worked examples in his blog posts, including some macros to help automate the tasks..
Leo9
Quartz | Level 8

I could not fine anything which specifically does this task. I example of reading excel file and reading one dataset at a time but nothing related to what I need. 

Reeza
Super User

I'd recommend taking the example that does one file and figure out how to generalize it to all. 

X commands definitely work though. 

 


@Leo9 wrote:

I could not fine anything which specifically does this task. I example of reading excel file and reading one dataset at a time but nothing related to what I need. 


 

ballardw
Super User

My approach to something like this would be to

1) us appropriate tool to unzip to desired location with system tools.

2) assign a library to that location.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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