<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: validating an hyperlink in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604092#M175090</link>
    <description>&lt;P&gt;Thanks. I will look into it.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2019 13:29:13 GMT</pubDate>
    <dc:creator>xxformat_com</dc:creator>
    <dc:date>2019-11-14T13:29:13Z</dc:date>
    <item>
      <title>validating an hyperlink</title>
      <link>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604084#M175086</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is there any procedure... which could be used to validate an hyperlink?&lt;/P&gt;&lt;P&gt;Background for the question is this paper where hyperlinks are checked using Python:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2019/AD/PharmaSUG-2019-AD-211.pdf" target="_blank" rel="noopener"&gt;https://www.lexjansen.com/pharmasug/2019/AD/PharmaSUG-2019-AD-211.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Véronique&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 12:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604084#M175086</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2019-11-14T12:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: validating an hyperlink</title>
      <link>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604091#M175089</link>
      <description>&lt;P&gt;Here’s a paper on working with urls in SAS:&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi30/100-30.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi30/100-30.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I imagine you’ll approach this problem by reading the http response of a get request to the url and if status=200 then the link checks out?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 14:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604091#M175089</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-14T14:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: validating an hyperlink</title>
      <link>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604092#M175090</link>
      <description>&lt;P&gt;Thanks. I will look into it.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 13:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604092#M175090</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2019-11-14T13:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: validating an hyperlink</title>
      <link>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604176#M175120</link>
      <description>&lt;P&gt;Assuming you have working urls, you can check the status and message as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro checkurl(lib=,url_dset=,url_out=);
%local num i currenturl;

%let dsid = %sysfunc(open(&amp;amp;url_dset.));
%let num  = %sysfunc(attrn(&amp;amp;dsid,nlobs));
%let rc   = %sysfunc(close(&amp;amp;dsid));

%do i=1 %to &amp;amp;num;

data _null_;
  p = &amp;amp;i;
  set &amp;amp;url_dset. point=p;
  call symputx('currenturl',URL);
  stop;
run;

proc http 
   url="&amp;amp;currenturl" 
   headerout=headout;
run;
data TEMP_&amp;amp;i.;
length url $200.;
infile headout scanover truncover;
input @'HTTP/1.1' code 4. message $255.;
if _n_=1 then do;
url="&amp;amp;currenturl";
output;
end;
run;

%end;

proc sql noprint;
select memname into :temp_dsets separated by " " from dictionary.tables where libname="&amp;amp;lib" and memname like 'TEMP%';
quit;

data &amp;amp;url_out.;
set &amp;amp;temp_dsets.;
run;

proc delete data=&amp;amp;temp_dsets; run;

%mend;

filename headout TEMP;

data myurls;
length url $200.;
input url $;
datalines;
http://httpbin.org/get
http://httpbin.org/post
;
run;

%checkurl(lib=WORK,url_dset=myurls,url_out=check);

proc print data=check; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, notice what happens when I run proc http on a fake url.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc http
   url="http://fake.website" 
   headerout=headout;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's an attempt to see what happens in this case (from the docs &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=proc&amp;amp;docsetTarget=n1ietrp9bhfq65n1px6nxl6vp9df.htm&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=proc&amp;amp;docsetTarget=n1ietrp9bhfq65n1px6nxl6vp9df.htm&amp;amp;locale=en&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro prochttp_check_return(url=,code=);
proc http url="&amp;amp;url";
run;
%if %symexist(SYS_PROCHTTP_STATUS_CODE) ne 1 %then %do;
  %put ERROR: Expected &amp;amp;code., but a response was not received from
 the HTTP Procedure;
  %abort;
  %end;
%else %do;
  %if &amp;amp;SYS_PROCHTTP_STATUS_CODE. ne &amp;amp;code. %then %do;
   %put ERROR: Expected &amp;amp;code., but received &amp;amp;SYS_PROCHTTP_STATUS_CODE.
 &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;
   %abort;%end;
%end;
%mend;

%prochttp_check_return(url=http://fake.website,code=200);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/validating-an-hyperlink/m-p/604176#M175120</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-14T16:34:40Z</dc:date>
    </item>
  </channel>
</rss>

