<?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: What is the purpose of rc if it’s never checked? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762213#M241303</link>
    <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; for your great help.  ACCEPTED SOLUTION (I need to correct that).</description>
    <pubDate>Wed, 18 Aug 2021 02:56:27 GMT</pubDate>
    <dc:creator>PopCorn14</dc:creator>
    <dc:date>2021-08-18T02:56:27Z</dc:date>
    <item>
      <title>What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761305#M240882</link>
      <description>&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Hi,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Many times, I see in code that we assign a value to a return code variable like rc (see examples below) however that rc variable is never checked down the road.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Calibri" size="2" color="#333333"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Examples:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;rc=filename ("fdir","&amp;amp;path");&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Calibri" size="2"&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Calibri" size="2"&gt;&lt;SPAN&gt;%let rc=%sysfunc(grdsvc_enable(_all_,resource=SASApp));&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Calibri" size="2"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Can someone explain to me the purpose of assigning rc if we do not check its value to continue? &amp;nbsp;I would expect something like this below but it is never the case.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;If rc&amp;gt;0 then…..continue &lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Else …&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#333333"&gt;Thank you.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 12 Aug 2021 22:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761305#M240882</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-12T22:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761307#M240884</link>
      <description>&lt;P&gt;Checking the return code is optional but I would regard it as a best practice check if following processing relies on it being successful. Not doing it is an example of lazy and potentially unreliable programming practices.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I always check these if required and I've seen a lot of code examples done by others also doing this.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 22:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761307#M240884</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-08-12T22:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761308#M240885</link>
      <description>&lt;P&gt;There are a lot of RC's in SAS.&amp;nbsp; The RC's from functions, well, some matter more than others.&amp;nbsp; The ones from a hash lookup, a FIND() in other words, I &lt;EM&gt;always&lt;/EM&gt; check.&amp;nbsp; If you're doing direct file reading FOPEN, etc., checking the RC is definitely best practice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also routinely check other RC's, the ones returned from Data an Procedure steps, via a macro and write them to my log at the end of a run.&amp;nbsp; I find this extremely helpful.&lt;/P&gt;
&lt;PRE&gt;       +-----------------------------------------------------------------------------------------------------------------+
       | Return codes and Sys messages as of 2021/08/12 18:09:23.73
       | SYSERR             =  0
       | SYSCC              =  0
       | SYsrc=0
       | SYSFILRC           =  1
       | SYSLIBRC           =  0
       | SYSLCKRC           =  0
       | SQLEXITCODE        =  0
       | SQLRC              =  0
       | SQLXRC             =  0
       | ReturnCode         =  0
       | Abort              =  0
       | SysErrorText       =     
       | Save_ErrorText     =     
       | SysWarningText txt =    
       | Save_WarningText   =    
       +-----------------------------------------------------------------------------------------------------------------+
&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 23:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761308#M240885</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-08-12T23:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761322#M240894</link>
      <description>&lt;P&gt;In some cases the function call may be confused with something else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One example:&lt;/P&gt;
&lt;PRE&gt;433  data _null_;
434    filename('somefile',"D:\Users\Owner\DATA\Super\examples.csv");
                                                                    -
                                                                    22
                                                                    76
ERROR: Undeclared array referenced: filename.
ERROR 22-322: Syntax error, expecting one of the following: +, =.

ERROR 76-322: Syntax error, statement will be ignored.

435  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


436
437  data _null_;
438    rc=filename('somefile',"D:\Users\Owner\DATA\Super\examples.csv");
439  run;

&lt;/PRE&gt;
&lt;P&gt;In the case of FILENAME you do have a statement of the same name with different syntax. So the compiler expects certain elements depending on the syntax attempted and if you use a call that looks like the function then it expects a target variable to assign the code to for success or not.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2021 00:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761322#M240894</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-13T00:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761354#M240918</link>
      <description>&lt;P&gt;The result of the FILENAME function is often not checked because the next step is a call to the FOPEN or DOPEN function, and that will fail if the FILENAME did not work, so the check there covers both:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc = filename(fref,path);
fid = fopen(fref);
if fid then ....&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Aug 2021 05:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/761354#M240918</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-13T05:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762210#M241300</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;. &amp;nbsp;I selected your answer for ACCEPTED SOLUTION but not sure what happened. &amp;nbsp;I will try to correct that.&lt;/P&gt;
&lt;P&gt;Your answer made a lot of sense and was well illustrated with your example. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 03:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762210#M241300</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-18T03:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762211#M241301</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37107"&gt;@jimbarbour&lt;/a&gt; for the list of all the return codes.</description>
      <pubDate>Wed, 18 Aug 2021 02:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762211#M241301</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-18T02:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762212#M241302</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; for your explanation.</description>
      <pubDate>Wed, 18 Aug 2021 02:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762212#M241302</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-18T02:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762213#M241303</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; for your great help.  ACCEPTED SOLUTION (I need to correct that).</description>
      <pubDate>Wed, 18 Aug 2021 02:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762213#M241303</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-18T02:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: What is the purpose of rc if it’s never checked?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762214#M241304</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; for your reply.</description>
      <pubDate>Wed, 18 Aug 2021 02:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-purpose-of-rc-if-it-s-never-checked/m-p/762214#M241304</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2021-08-18T02:57:23Z</dc:date>
    </item>
  </channel>
</rss>

