BookmarkSubscribeRSS Feed
RyanSimmons
Pyrite | Level 9

I am having difficulty trying to open a zipped SAS dataset. There seem to be very few examples of this that I can find online, and none of them offer a clue as to how to solve my problem. 

 

If I run the following code, I can see that SAS is successfully recognizing the zip file and its contents (I edited out the path for anonymity, but "path" in the below is a valid path to an existing directory on the machine):

 

filename inzip ZIP "path\CoBISII-InterimAnalysis20190618.zip";

DATA contents(keep=memname);
 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=contents noobs N;
run;

This produces the following output:

memname
mrsdata.sas7bdat
Readme.xlsx
N = 2

 

I want to read the SAS dataset (mrsdata) into SAS. I tried following the example here and used the following code:

 

filename wc "%sysfunc(getoption(work))/mrsdata.sas7bdat";

DATA _null_;
	infile inzip(mrsdata.sas7bdat) lrecl=256 recfm=F length=length eof=eof unbuf;
	file wc lrecl=256 recfm=N;
	input;
	put _infile_ $varying256. length;
	return;
	eof:
	stop;
run;

PROC CONTENTS data=WORK.mrsdata;
run;

However, this produces the following error (again, I am editing out the path for anonymity's sake):

 

ERROR: Open failure for path\CoBISII-InterimAnalysis20190618.zip during attempt to create a local file handle.
NOTE: UNBUFFERED is the default with RECFM=N.
NOTE: The file WC is:
Filename=C:\tmp\wc.dat,
RECFM=N,LRECL=256,File Size (bytes)=0,
Last Modified=24Jun2019:14:39:38,
Create Time=24Jun2019:14:39:38

 

I am at a complete loss as to how to proceed. 

5 REPLIES 5
Tom
Super User Tom
Super User

Your INFILE statement is missing quotes around the name of the member in the ZIP file.

infile inzip("mrsdata.sas7bdat")  ...
RyanSimmons
Pyrite | Level 9

I'm fairly certain that quotes there are not needed. There are plenty of examples online that don't use the quotes and seem to work. Further, if I use the quotes with my example, I get the same exact error message, it doesn't change the behavior at all.

Tom
Super User Tom
Super User

That is too bad that quoting wasn't the issue, would have been a trivial fix.

 

You can also try adding the member name to the FILENAME statement.  Use MEMBER="name".

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsglobal&docsetTarge...

 

Then it should be easier for you to use the FCOPY() function to extract the SAS7BDAT file.  See Example 2.

https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#n10dz22b5...

 

 

RyanSimmons
Pyrite | Level 9

Thanks for the suggestion. Unfortunately, I get the same error message:

 

rc=10005
msg=ERROR: Open failure for Z:\CRU\Pediatrics\Active Projects\CoBIS II\raw data\CoBISII-InterimAna
lysis20190618.zip during attempt to create a local file handle.

 

10005 is the error code returned by FCOPY; not sure if there is any meaning to be gleaned from that. 

 

I do see that the documentation for FILENAME's ZIP access method states, "The ZIP access method reads and writes only files created with the WinZip file compression." I'm not sure how this .zip file was created, but I'm wondering if the issue was that it wasn't using WinZip.

Tom
Super User Tom
Super User
Make sure that the physical ZIP file can actually be seen by SAS. Perhaps you have the path wrong. Or you have a path for a different machine than the machine that is running SAS. Or perhaps the userid that is running the SAS code does not have access to the file.
Also make sure that you can read the ZIP file with some other utility. Perhaps you really do have a damaged file.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 4428 views
  • 0 likes
  • 2 in conversation