<?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: Using SAS system return codes to control processing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39382#M7971</link>
    <description>A libname statement sets the automatic macro variable &amp;amp;SYSLIBRC&lt;BR /&gt;
&lt;BR /&gt;
have a look at it's online doc....&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543774.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543774.htm&lt;/A&gt;  .&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
    <pubDate>Sun, 17 Aug 2008 08:24:10 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2008-08-17T08:24:10Z</dc:date>
    <item>
      <title>Using SAS system return codes to control processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39380#M7969</link>
      <description>Hi Guys.&lt;BR /&gt;
&lt;BR /&gt;
I have a Data _Null_ step [see (2) below] that &lt;BR /&gt;
(1) creates a macro variable &amp;amp;PATH containing a SAS library name.&lt;BR /&gt;
(2) performs a call execute statement on macro MMM1 [see (1) below]. &lt;BR /&gt;
 &lt;BR /&gt;
Macro MMM1 allocates a Library "LIB" based on the data contained in &amp;amp;PATH &amp;amp; then performs a Proc sort on a file in the named Library.&lt;BR /&gt;
&lt;BR /&gt;
Problem :- sometimes the Library does not exist and so, consequently, the Proc sort fails.&lt;BR /&gt;
When the Libname statement creates a Library that does not exist, a "note" to that effect appears in the SAS log.&lt;BR /&gt;
When the Proc statement executes, it (understandably) causes a SAS error.&lt;BR /&gt;
&lt;BR /&gt;
Question :&lt;BR /&gt;
How can I use the SAS system return codes to trap the "note" warning about the Library not existing to prevent the subsequent Proc sort from executing?&lt;BR /&gt;
&lt;BR /&gt;
/** (1) **/&lt;BR /&gt;
%MACRO MMM1(PATH=);&lt;BR /&gt;
   Data _NULL_;&lt;BR /&gt;
      LIBNAME LIB "&amp;amp;PATH";&lt;BR /&gt;
      &lt;BR /&gt;
      PROC SORT DATA=LIB.filename;&lt;BR /&gt;
                BY DATETIME;&lt;BR /&gt;
      RUN;&lt;BR /&gt;
   run;&lt;BR /&gt;
%MEND MMM1;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/** (2) **/&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
   Attrib PATH Length=$40;&lt;BR /&gt;
   SET IN_REC(KEEP=Part3);&lt;BR /&gt;
       PATH = '/DIR1/DIR2/'||Part3||'/DIR4/';&lt;BR /&gt;
       Call execute('%MMM1(PATH=' || PATH || ')');&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
There is a lot of general info on SYSRC in the SAS manuals, in particular something called _SWNOLIB looks very promising. Its probably very straightforward, but there are not enough "examples" in the manuals (for me) to be able to decipher how to actually make it work.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for any advice</description>
      <pubDate>Fri, 15 Aug 2008 07:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39380#M7969</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-15T07:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS system return codes to control processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39381#M7970</link>
      <description>Depending on your OS, review the SAS functions such as FILEEXIST (as well as other like-purpose functions) and you can use %SYSFUNC with one of these functions in a macro.  If you want to maintain your DATA step outside the macro, set a %GLOBAL statement at the start of your macro and test the "&amp;amp;MYGLOBAL" in a DATA step IF, placed "BEFORE" the SET statement, and issue a STOP when you have detected that the path does not exist.&lt;BR /&gt;
&lt;BR /&gt;
Also, consider that the entire DATA step could be executed within your macro, using SAS macro language SAS data member read functions, FOPEN, FREAD, FCLOSE.&lt;BR /&gt;
&lt;BR /&gt;
Suggest you scan the SAS.COM support site for examples and SUGI/SGF papers on these topic-areas; also there is a related link pasted below.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a000210912.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a000210912.htm&lt;/A&gt;</description>
      <pubDate>Fri, 15 Aug 2008 12:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39381#M7970</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-08-15T12:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using SAS system return codes to control processing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39382#M7971</link>
      <description>A libname statement sets the automatic macro variable &amp;amp;SYSLIBRC&lt;BR /&gt;
&lt;BR /&gt;
have a look at it's online doc....&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543774.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543774.htm&lt;/A&gt;  .&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Sun, 17 Aug 2008 08:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SAS-system-return-codes-to-control-processing/m-p/39382#M7971</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2008-08-17T08:24:10Z</dc:date>
    </item>
  </channel>
</rss>

