FILENAME has optional arguments such as TEMP, ZIP, URL, etc. Can one use two or more arguments simultaneously? For example, can FILENAME refer a zip file on the Internet as follows?
filename myfile zip url "http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_TXT.zip";
Or can FILENAME be a temporary zip file? Probably not as the SAS document says ZIP must be a ufs file and it seems TEMP is not.
filename myfile temp zip;
I tried several arguments simultaneously but didn't work. Thanks for help.
You cannot ask SAS to run two different filename engines in the same filename.
Copy the file to your local machine. Then you can use the ZIP engine to extract something from the file.
filename webfile url
'https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip'
recfm=f lrecl=512
;
filename middle temp recfm=f lrecl=512;
data _null_;
rc=fcopy('webfile','middle');
if rc then do;
length msg $ 384;
msg=sysmsg();
put rc= msg=;
end;
run;
filename text zip "%sysfunc(pathname(middle))" member='*' ;
Now you can read the text out of the zip file:
data want ;
infile text truncover firstobs=5 dsd ;
input var1-var5 ;
run;
You can specify one file within the zip, if that is what you need:
filename foo ZIP 'U:\directory1\testzip.zip' member="test1.txt" ;
Example 1 in https://documentation.sas.com/?docsetId=lestmtsglobal&docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&...
Thanks, but suppose that the zip file is now on the Internet as follows.
https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip
Can I feed one member of this url as the FILENAME?
You cannot ask SAS to run two different filename engines in the same filename.
Copy the file to your local machine. Then you can use the ZIP engine to extract something from the file.
filename webfile url
'https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip'
recfm=f lrecl=512
;
filename middle temp recfm=f lrecl=512;
data _null_;
rc=fcopy('webfile','middle');
if rc then do;
length msg $ 384;
msg=sysmsg();
put rc= msg=;
end;
run;
filename text zip "%sysfunc(pathname(middle))" member='*' ;
Now you can read the text out of the zip file:
data want ;
infile text truncover firstobs=5 dsd ;
input var1-var5 ;
run;
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!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.