03-04-2015 10:21 PM
I am trying to read some URL webpages into SAS from an input file that contains links to URLs (fname_full). However, some of the links are not longer valid on the web. When SAS runs the codes, it will stop and generate error if one of the links no longer exist on the web. I wonder how I can automatically skip those lines of URLs that generate error because the links no longer exists on the web and produce an output for those lines that the URL exists.
Excerpts of code:
infile datfiles URL filevar=%STR(&fname_full) end=lastline;
ERROR: Invalid reply received from the HTTP server. Use the debug option for more info.
03-05-2015 06:24 AM
I think you will need to use the filename(), fopen(), fread(), fget() functions, and check return codes.
Here is an example:
length text $ 10;
rc2=fread(fid);/*reading 1 line*/
rc3=fget(fid, text, 10);/*reading 10 characters*/
putlog rc1= fid= rc2= rc3= text= rc4= _ERROR_=;