<?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: How to set return code = 2 for SAS program? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/691015#M210269</link>
    <description>&lt;P&gt;Thank you for that,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&amp;nbsp; I'm surprised one has to code ABORT &lt;STRONG&gt;ABEND&lt;/STRONG&gt; 2, since I used to code ABORT &lt;STRONG&gt;RETURN&lt;/STRONG&gt; 2 when I had a job where we ran on a mainframe and checked return codes at the JCL level frequently.&amp;nbsp; Usually SAS tries to be uniform across platforms.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current job uses Windows.&amp;nbsp; I don't have much occasion to check return codes after SAS executes, but if I get time, I'll have to see how return codes post-SAS work in Windows.&amp;nbsp; You've gotten me curious.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 16:59:56 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-10-12T16:59:56Z</dc:date>
    <item>
      <title>How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690818#M210186</link>
      <description>&lt;P&gt;I set the code to "abort return 4", but it did not set overall sas program RC=2.&amp;nbsp; How can I set the RC=2 when I abort the program?&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 20:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690818#M210186</guid>
      <dc:creator>niejung</dc:creator>
      <dc:date>2020-10-11T20:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690822#M210188</link>
      <description>&lt;P&gt;What kind of a system are you running on? &amp;nbsp;On a mainframe, Abort Return 2 definitely sets the overall return code and can be queried by downstream steps in the JCL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are talking about the internal return code inside SAS, that's the macro variable SYSCC. &amp;nbsp;In a data step, it can be set:&lt;/P&gt;
&lt;P&gt;CALL SYMPUTX('SYSCC', 2, 'G');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In open code, non-Data step code:&lt;/P&gt;
&lt;P&gt;%LET SYSCC = 2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then query &amp;amp;SYSCC in downstream code, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%IF &amp;amp;SYSCC &amp;lt; 2 %THEN&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %DO;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... Code goes here...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%END;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not necessary to create a macro in order have a %IF in open code if you are on SAS 9.4 &lt;STRONG&gt;M5&lt;/STRONG&gt; or higher. &amp;nbsp;The %DO and %END are required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 20:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690822#M210188</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-11T20:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690824#M210189</link>
      <description>&lt;P&gt;I am running SAS program from SAS GRID server.&amp;nbsp; I have a condition if HTTP response is not equal to 200, then abort the program.&amp;nbsp; The program did abort it, but RC code is 1.&amp;nbsp; &amp;nbsp;I like to know how I can overwrite the return code to 2.&amp;nbsp; The version of the program is old.&amp;nbsp; 9.4 M3.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 20:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690824#M210189</guid>
      <dc:creator>niejung</dc:creator>
      <dc:date>2020-10-11T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690825#M210190</link>
      <description>&lt;P&gt;The statement would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;abort abend 2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 20:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690825#M210190</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-11T20:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690830#M210192</link>
      <description>&lt;P&gt;When you say "RC," are you talking at the OS level (outside SAS)?&amp;nbsp; Or are you talking about inside SAS?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a lot of return codes inside SAS:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SYSERR&lt;/LI&gt;
&lt;LI&gt;SYSCC&lt;/LI&gt;
&lt;LI&gt;SYSRC&lt;/LI&gt;
&lt;LI&gt;SYSFILRC&lt;/LI&gt;
&lt;LI&gt;SYSLIBRC&lt;/LI&gt;
&lt;LI&gt;SYSLCKRC&lt;/LI&gt;
&lt;LI&gt;SQLEXITCODE&lt;/LI&gt;
&lt;LI&gt;SQLRC&lt;/LI&gt;
&lt;LI&gt;SQLXRC&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The most critical return codes (in my opinion) in the context of a SAS program are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SYSCC -- master return code used &lt;EM&gt;inside&lt;/EM&gt; of SAS programs.&lt;/LI&gt;
&lt;LI&gt;SYSRC -- the return code from operations submitted via the X command (or similar commands) to the O/S.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Be judicious in the use of SYSRC.&amp;nbsp; I've seen the OS react strangely to a SYSRC set manually in a SAS program run in UNIX.&amp;nbsp; I typically try not to touch SYSRC, but I suppose there could be times where it would be appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 23:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690830#M210192</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-11T23:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690836#M210193</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p07ugdul4v0llpn1denhfknmr7sb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYSRC&lt;/A&gt; holds the return code of the most recently executed (via X or %SYSEXEC) external command. It's got nothing to do with the return code of the SAS session itself.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p11nt7mv7k9hl4n1x9zwkralgq1b.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYSCC&lt;/A&gt;&amp;nbsp;is the one that holds (or corresponds to) the exit code of the SAS session.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 22:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690836#M210193</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-11T22:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690839#M210194</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hmmm.&amp;nbsp; Interesting.&amp;nbsp; All I can say is that at my last job when working on a UNIX (POSIX) OS computer that when I set SYS&lt;STRONG&gt;RC&lt;/STRONG&gt; manually that some very strange things happened.&amp;nbsp; I assumed it was being passed back to the OS, but from what you're saying, that is incorrect.&amp;nbsp; I would definitely agree that SYSRC contains the return code from, say, an unzip executed via an X command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At least in UNIX, I've seen that SYS&lt;STRONG&gt;CC&lt;/STRONG&gt; affects the return code at the OS level, but it wasn't 1:1.&amp;nbsp; For example a SYSCC of 8 would result in an OS return code of (going on memory here) 1.&amp;nbsp; As I think about it, that's probably what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/336655"&gt;@niejung&lt;/a&gt;&amp;nbsp;is asking about since a SAS grid is typically UNIX or LINUX.&amp;nbsp; I was thinking that SYSRC was the one to set for that, but apparently not.&amp;nbsp; I've been on Windows lately, so I probably shouldn't rely on my poor memory for Unix/Linux.&amp;nbsp; I deleted my earlier remarks about SYSRC.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 23:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690839#M210194</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-11T23:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690884#M210206</link>
      <description>&lt;P&gt;Yes, the only SYSCC code that is handed to the OS as is is zero; I've seen numbers like 1012 that resulted in a return code of 2 (ERROR).&lt;/P&gt;
&lt;P&gt;The proper way to force the return code is the ABORT ABEND.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 05:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/690884#M210206</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-12T05:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/691015#M210269</link>
      <description>&lt;P&gt;Thank you for that,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&amp;nbsp; I'm surprised one has to code ABORT &lt;STRONG&gt;ABEND&lt;/STRONG&gt; 2, since I used to code ABORT &lt;STRONG&gt;RETURN&lt;/STRONG&gt; 2 when I had a job where we ran on a mainframe and checked return codes at the JCL level frequently.&amp;nbsp; Usually SAS tries to be uniform across platforms.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My current job uses Windows.&amp;nbsp; I don't have much occasion to check return codes after SAS executes, but if I get time, I'll have to see how return codes post-SAS work in Windows.&amp;nbsp; You've gotten me curious.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 16:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/691015#M210269</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-12T16:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to set return code = 2 for SAS program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/691175#M210330</link>
      <description>&lt;P&gt;I think that ABORT RETURN should also work on all platforms; the use of ABORT ABEND here is probably a remnant of our mainframe past, where ABEND seems to have consequences with regards to the JCL scripts and scheduler that probably do not exist on other systems.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 08:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-return-code-2-for-SAS-program/m-p/691175#M210330</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-13T08:59:17Z</dc:date>
    </item>
  </channel>
</rss>

