BookmarkSubscribeRSS Feed
zilong567
Calcite | Level 5

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.

2 REPLIES 2
SuzanneDorinski
Lapis Lazuli | Level 10

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.

Reeza
Super User
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.

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