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.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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