unzip sas7bdat.gz file

Reply
New Contributor
Posts: 3

unzip sas7bdat.gz file

I tried all the solutions on the internet and failed. Hope you could help me with the case.

The url link of the data: http://scholar.rhsmith.umd.edu/sites/default/files/sbrown/files/pins_vdj_ann.sas7bdat.gz?m=146736684...
My code:
libname pinlib "E:\data\PIN_Stephen_Brown";
filename target "%sysfunc(pathname(pinlib))/test.sas7bdat";
filename fromzip ZIP "E:\data\PIN_Stephen_Brown\test.sas7bdat.gz";
data _null_;
infile fromzip
lrecl=256 recfm=F length=length eof=eof unbuf;
file target lrecl=256 recfm=N;
input;
put _infile_ $varying256. length;
return;
eof:
stop;
run;
It reports the error message as :
ERROR: The file "E:\data\PIN_Stephen_Brown\test.sas7bdat.gz" exists and is not a zip
file. The output file must be a zip file.
I appreciate your help very much if you could help me with this case.

Your comment is awaiting moderation.

Frequent Contributor
Posts: 118

Re: unzip sas7bdat.gz file

Posted in reply to zilong567

I think you need to add GZIP to the filename statement that refers to the .gz file.

 

This code worked for me in SAS University Edition:

 

filename target "/folders/myfolders/GZIP/pins_vdj_ann.sas7bdat";
filename fromzip ZIP "/folders/myfolders/GZIP/pins_vdj_ann.sas7bdat.gz" GZIP;

data _null_;
	infile fromzip lrecl=256 recfm=F length=length eof=eof unbuf;
	file target lrecl=256 recfm=N;
	input;
	put _infile_  $varying256. length;
	return;
  eof:
    stop;
run;

Chris Hemedinger provided the syntax to expand the data set in a comment on Reading and writing GZIP files with SAS.

Super User
Posts: 23,662

Re: unzip sas7bdat.gz file

Posted in reply to zilong567
What version of SAS do you have? Support for GZ was only added recently, before that it supported WinZip only.

The link in @SuzanneDorinkski has the details.
Ask a Question
Discussion stats
  • 2 replies
  • 83 views
  • 0 likes
  • 3 in conversation