<?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 protect dataset after error? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90196#M25751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code is just an example; I want to find a mothod deal with error,and when error happend not go ahead to anything,&lt;/P&gt;&lt;P&gt;another example:After the following code is finshed I don't want sashelp.class be replaced.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;data errorone;/*This dataset just for generate an error */&lt;/P&gt;&lt;P&gt;set noexist;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*when error happened next step should not be run,----------how to do it?? */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sashelp.class;&lt;/P&gt;&lt;P&gt;set errorone;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2012 17:19:11 GMT</pubDate>
    <dc:creator>Mike_Davis</dc:creator>
    <dc:date>2012-06-22T17:19:11Z</dc:date>
    <item>
      <title>How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90194#M25749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When run a SAS using interactive mode, when error happened,how to stop the code and not override the rest dataset with an empty dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if we select the follow three datasteps and submit them together, in the first step,dataset 'a' would be created ,&lt;/P&gt;&lt;P&gt;then in the second ,there will be a error bacuse no dataset named sashelp.class_notexist .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then in the third step, dataset 'a' will be &lt;STRONG&gt;&lt;EM&gt;destroyed&lt;/EM&gt;&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to specify an option to protect dataset 'a' after error happen? so when an error happen SAS&amp;nbsp; will stop do any other thing and keep dataset 'a' as the first step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;set sashelp.class_notexist;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;set one;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 16:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90194#M25749</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-22T16:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90195#M25750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are many solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One is simply using different programming practice, where you don't reuse the names of datasets in a program. Then data a never gets overwritten because the last data step is named data b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other way that comes to mind is to check the number of observations in data one, and if you find out that data one has zero observations, you don't perform the next step. I'm pretty sure you would have to do this with macros.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 17:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90195#M25750</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2012-06-22T17:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90196#M25751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code is just an example; I want to find a mothod deal with error,and when error happend not go ahead to anything,&lt;/P&gt;&lt;P&gt;another example:After the following code is finshed I don't want sashelp.class be replaced.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;data errorone;/*This dataset just for generate an error */&lt;/P&gt;&lt;P&gt;set noexist;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*when error happened next step should not be run,----------how to do it?? */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sashelp.class;&lt;/P&gt;&lt;P&gt;set errorone;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 17:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90196#M25751</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-22T17:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90197#M25752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I understand your code is an example. But now you have provided more code, which is also an example, and ignored my suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I said, the simplest way is to not re-use dataset names in your code. Then sashelp.class doesn't get replaced. Is that not a valid solution for you?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I said, you can check to see how many observations are in errorone, and if it is zero, do not perform the next step. Is that not a valid solution for you?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 17:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90197#M25752</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2012-06-22T17:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90198#M25753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I think you must mis-understand my question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I need the dataset to be override by another dataset&amp;nbsp; if there was no error happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.As you said ,you can check error and not perform next if error there,this sounds like the solution I need ,but what is it? I will be very appreciate if you would show me the detail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 20:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90198#M25753</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-22T20:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90199#M25754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To get the most control you would need to wrap your code into a macro. Then you can use macro logic at key points to stop processing.&amp;nbsp; Using you simple example you could do something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set sashelp.class_notexist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%if not &amp;amp;syserr %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; data a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%a;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jun 2012 19:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90199#M25754</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-23T19:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90200#M25755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can check for specific conditions (using macro language).&amp;nbsp; But you cannot check for "any sort of error" until after the DATA step runs.&amp;nbsp; Here are a few tools that may come in handy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fileexist checks for the existence of a folder or raw data file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;exist checks for the existence of a SAS data set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you could (inside a macro) code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if %sysfunc(exist(mylib.my_dataset)) %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then the %do group code would only run when your SAS data set exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that the sort of thing you are looking for?&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Jun 2012 02:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90200#M25755</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-06-24T02:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90201#M25756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need a special dataset option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPEMPTY= Data Set Option&lt;/P&gt;&lt;P&gt;Specifies whether a new, empty data set can overwrite an existing SAS data set that has the same&lt;/P&gt;&lt;P&gt;name.&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;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 02:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90201#M25756</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-06-25T02:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90202#M25757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Also ,For both the convenience of replacing existing data sets with new ones that contain data and the protection of not overwriting existing data sets with new empty ones that are created by accident, set REPLACE=YES and REPEMPTY=NO.&lt;/P&gt;&lt;P&gt;one thing need to be mentioned, system options will replace only permernent dataset,&lt;/P&gt;&lt;P&gt;temperory dataset need to use replace=&amp;nbsp; dataset option&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 19:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90202#M25757</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-25T19:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to protect dataset after error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90203#M25758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about the following code ,please advise me,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;set notexist;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%let ee=&amp;amp;syserr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro diablo3(monk);&lt;/P&gt;&lt;P&gt;data a(%if &amp;amp;monk=1 %then %do; replace=no %end; %else %do; replace=yes %end);&lt;/P&gt;&lt;P&gt;set one;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend diablo3;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%diablo3(monk=&amp;amp;ee);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 20:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-protect-dataset-after-error/m-p/90203#M25758</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-25T20:06:08Z</dc:date>
    </item>
  </channel>
</rss>

