<?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: Error Checking at Libref Statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637940#M189681</link>
    <description>&lt;P&gt;Are you looking for the LIBREF() function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname AECS DB2 datasrc=FDWXX schema=FDWATOM user=&amp;amp;u_alias password=&amp;amp;u_password;
%if %sysfunc(libref(AECS)) %then %do;
  endsas;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps just the ERRORABEND option?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options errorabend;
libname AECS DB2 datasrc=FDWXX schema=FDWATOM user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 06 Apr 2020 20:41:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-06T20:41:19Z</dc:date>
    <item>
      <title>Error Checking at Libref Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637935#M189679</link>
      <description>&lt;P&gt;Myself and many other colleagues use librefs to connect to several libraries on our server each time we run a program. In order to access the library, a password is required and is supplied using a prompt. Our problem is that you only get three chances to enter your password and then you are locked out, so if one accidentally enters their password while trying to connect to 3+ libraries, they are locked out on the first try. I am trying to use a macro to check whether there was an error after the first libref statement and if so, to exit the program before executing the second libref statement. If not, continue with the remainder of the program. I thought the macro below worked in the past but I am either mistaken, or something changed and it no longer works. Does anyone know how to acheive this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro check_for_errors;&lt;BR /&gt;%if &amp;amp;syserr &amp;gt; 0 %then %do;&lt;BR /&gt;endsas;&lt;BR /&gt;%end;&lt;BR /&gt;%mend check_for_errors;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname AECS DB2 datasrc=FDWXX schema=FDWATOM user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;BR /&gt;%check_for_errors&lt;BR /&gt;libname ECS DB2 datasrc=FDWXX schema=FDWECS user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;BR /&gt;Libname AE DB2 datasrc=FDWXX schema=FDWAE user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;BR /&gt;libname QV DB2 datasrc=FDWXX schema=FDWQV user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 20:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637935#M189679</guid>
      <dc:creator>mnvandyke06</dc:creator>
      <dc:date>2020-04-06T20:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error Checking at Libref Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637940#M189681</link>
      <description>&lt;P&gt;Are you looking for the LIBREF() function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname AECS DB2 datasrc=FDWXX schema=FDWATOM user=&amp;amp;u_alias password=&amp;amp;u_password;
%if %sysfunc(libref(AECS)) %then %do;
  endsas;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps just the ERRORABEND option?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options errorabend;
libname AECS DB2 datasrc=FDWXX schema=FDWATOM user=&amp;amp;u_alias password=&amp;amp;u_password;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 20:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637940#M189681</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T20:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error Checking at Libref Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637941#M189682</link>
      <description>&lt;P&gt;A better option might be to use the LIBNAME function then test the function return code which is 0 if the function worked successfully:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1bq8nyxm7y1ygn1i4vyf82z68ls.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p1bq8nyxm7y1ygn1i4vyf82z68ls.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 20:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/637941#M189682</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-04-06T20:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error Checking at Libref Statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/638350#M189828</link>
      <description>Libname was exactly what i was looking for. Thank you!!</description>
      <pubDate>Wed, 08 Apr 2020 16:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Checking-at-Libref-Statements/m-p/638350#M189828</guid>
      <dc:creator>mnvandyke06</dc:creator>
      <dc:date>2020-04-08T16:12:54Z</dc:date>
    </item>
  </channel>
</rss>

