<?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: catching errors in batch in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172728#M33182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think that will work.&amp;nbsp; I don't need only the affected SAS program to end but the following that are kicked off in the batch file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want to capture what the error is and control what happens next depending on the error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 17:25:03 GMT</pubDate>
    <dc:creator>wkossack_nspirehealth_com</dc:creator>
    <dc:date>2014-04-08T17:25:03Z</dc:date>
    <item>
      <title>catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172726#M33180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am updating some code that is executed in batch early in the morning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to modify the batch program to catch certain errors and terminate the run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've seen where you can send a sysparm value to SAS from the batch command to control how SAS runs but can you send anything back to batch from SAS (running on windows)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know about getting the ERRORLEVEL from the execution but I am more interested in specific parts of code.&amp;nbsp; For example, once and a while a libname to an ODBC data source fails&amp;nbsp; (never been able to figure out why).&amp;nbsp; If that happens I would like to catch the situation and force batch to stop the batch program&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 15:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172726#M33180</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2014-04-08T15:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172727#M33181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your desired behavior is a SAS system option, &lt;A href="https://support.sas.com/documentation/cdl/en/lesysoptsref/64892/HTML/default/viewer.htm#n074sx2hkq8dzpn1ptoydcmzfspt.htm" title="https://support.sas.com/documentation/cdl/en/lesysoptsref/64892/HTML/default/viewer.htm#n074sx2hkq8dzpn1ptoydcmzfspt.htm"&gt;SAS(R) 9.3 System Options: Reference, Second Edition&lt;/A&gt; (error checking strict)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172727#M33181</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-04-08T17:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172728#M33182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think that will work.&amp;nbsp; I don't need only the affected SAS program to end but the following that are kicked off in the batch file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want to capture what the error is and control what happens next depending on the error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172728#M33182</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2014-04-08T17:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172729#M33183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might have some control over the error code value sent by SAS back to the operating system using the ABORT statement.&lt;/P&gt;&lt;P&gt;If you need to pass more information back to the script that is calling SAS then you will need to define a location for SAS to write the information, such as a text file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172729#M33183</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-04-08T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172730#M33184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would look into a driver SAS job that uses SYSTASK to run the batch programs.&amp;nbsp; SYSTASK has options to capture the completion status among other things as I recall.&amp;nbsp; So depending on the status from jobA you can decide what to do the job B C and D...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172730#M33184</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-04-08T17:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172731#M33185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What will happen with this option is:&lt;/P&gt;&lt;P&gt;-&amp;nbsp; the running program will detect an error and set the errorlevel to nonzero&lt;/P&gt;&lt;P&gt;- going into syntax-mode nothing else will be execute as follow up&lt;/P&gt;&lt;P&gt;- the log file of this program will still be created. You can still see all things there&lt;/P&gt;&lt;P&gt;- As you should have you scheduling setup recognizing the errorlevel, what is your issue on that?&lt;/P&gt;&lt;P&gt;When you want the detect the succesfull completion of a libname that is another approach&lt;/P&gt;&lt;P&gt;That is not having error detection done by the SAS system but by yourself. Could be a smarter solution.&lt;/P&gt;&lt;P&gt;syslibrc is giving the status of a libname attempt &lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p0vnvc6k3fo349n1aszgd2ls6oxk.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p0vnvc6k3fo349n1aszgd2ls6oxk.htm"&gt;SAS(R) 9.3 Macro Language: Reference&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;You will have to code a macro for your logic what to do next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172731#M33185</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-04-08T17:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172732#M33186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you want can be accomplished.&amp;nbsp; In the 90's, when we had jobs stopping mid process, we made them not kick off future jobs and email us with all the particulars when the process stopped.&amp;nbsp; Most of the methods we used were found in User group Papers and SAS documents.&amp;nbsp; I bet you can find what you need if you Google it.&amp;nbsp; We used stop and notify methods because we had jobs running on the mainframe downloading SAS data to UNIX.&amp;nbsp; If any part of the process failed, we had to stop the remaining processes. Unfortunately I do not have copies of the coding.&amp;nbsp; The best way to begin is by changing your code to write your logs to datasets.&amp;nbsp; Then insert code at the end of each process step, that checks the dictionary tables to verify that the previious step created a dataset with more than zero obs.&amp;nbsp; After that we created a macro variable that held a "stop" or "go" value.&amp;nbsp; If the macro variable was a go, we processed the next step.&amp;nbsp; %put statements wrote the stop and go values to the log dataset.&amp;nbsp; If the macro was a stop, we emailed ourselves a note saying that the job did not run to normal completion. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172732#M33186</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-04-08T17:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172733#M33187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am debating using a master.sas program that controls all the other code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A master program would permit better control&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code runs fine most days but problems occur of and on and failures are not common&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 18:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172733#M33187</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2014-04-08T18:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172734#M33188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK....what do I need here to get trap the error in dataset test?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%macro &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;data junk; set jjjjjjj;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;/* trap error here */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%mend &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 20:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172734#M33188</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2014-04-08T20:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: catching errors in batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172735#M33189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;never mind&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%include&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt; rpt_bad;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%macro &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;/* trap error here */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%if &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;amp;syserr &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%let &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;error=&amp;amp;syserr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: green; font-family: 'Courier New'; font-size: 10pt;"&gt;/* code to process error conditgion here */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%put &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;amp;error;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 10pt;"&gt;%end&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;%mend &lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 20:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/catching-errors-in-batch/m-p/172735#M33189</guid>
      <dc:creator>wkossack_nspirehealth_com</dc:creator>
      <dc:date>2014-04-08T20:28:36Z</dc:date>
    </item>
  </channel>
</rss>

