BookmarkSubscribeRSS Feed
Delgoffe_MCRI
Obsidian | Level 7

When I run the following code to set the zip folder location and identify members...

 

/*Setting Zip folder Location*/

filename inzip ZIP "**location hidden for security**/datasetzippedfolder.zip";

/* Read the "members" (files) from the ZIP file */
data contents(keep=memname isFolder);
length memname $200 isFolder 8;
fid=dopen("inzip");
if fid=0 then
stop;
memcount=dnum(fid);
do i=1 to memcount;
memname=dread(fid,i);
/* check for trailing / in folder name */
isFolder = (first(reverse(trim(memname)))='/');
output;
end;
rc=dclose(fid);
run;
/* create a report of the ZIP contents */
title "Files in the ZIP file";
proc print data=contents noobs N;
run;

 

...I get the following:

 

memname isFolder
var/lib/jenkins/oracle_export/dataset.csv0
N = 1

 

 

The dataset.csv is size 777 PB. I do not want to extract this folder because I don't have the room. I know what columns the dataset has and what the value of the variable needs to be for the subset.

 

How can I achieve obtaining the subset without extracting?

3 REPLIES 3
ballardw
Super User

You would use the csv file name as the member argument in a filename statement:

 

filename foo ZIP 'U:\directory1\testzip.zip' member="test1.csv" ;

 

Then in your infile statement use the fileref Foo

 

data want;

   infile foo <any options such as delimeter, lrecl and such>;

   <informat and input statement for the columns in the csv go here>

run;

 

Note that if the Zip wasn't created by WinZip this may not work.

Delgoffe_MCRI
Obsidian | Level 7

Thank you for your quick feedback @ballardw.

 

Unfortunately, I get this error:

 

NOTE: The zip file dmf_table_33.csv doesn't exist.
ERROR: Physical file does not exist, dmf_table_33.csv.

 

It seems to not recognize the zipped folder. The files are password protected. Would that make a difference?

ballardw
Super User

@Delgoffe_MCRI wrote:

Thank you for your quick feedback @ballardw.

 

Unfortunately, I get this error:

 

NOTE: The zip file dmf_table_33.csv doesn't exist.
ERROR: Physical file does not exist, dmf_table_33.csv.

 

It seems to not recognize the zipped folder. The files are password protected. Would that make a difference?


From http://blogs.sas.com/content/sasdummy/2014/01/29/using-filename-zip/  :

For password-protected ZIP files, you'll still need to use external tools like WinZip, 7-Zip, or gzip. This SAS Global Forum paper shows how that can work.

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1525 views
  • 1 like
  • 2 in conversation