<?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: Creating a SAS Dataset basis SAS code run result in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594380#M170759</link>
    <description>&lt;P&gt;Create a little macro that inserts the error message into the data set. Add triggers into your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How that %IF/%THEN is structured will vary from program to program, but hopefully gives you an idea.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro add_error(error_code = , error_message = );

proc sql;
insert into mydb.Error_Log
values(&amp;amp;error_code, &amp;amp;error_message);
quit;

%mend;

proc sql;
create table test as
select name, weight, height, error
from sashelp.class;
quit;

%if _SYSERR_ %then %add_error("Mistake1", "Check program at Part2");

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 06 Oct 2019 22:56:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-10-06T22:56:55Z</dc:date>
    <item>
      <title>Creating a SAS Dataset basis SAS code run result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594369#M170752</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;I am looking for some ideas here.&lt;/P&gt;&lt;P&gt;I have a requirement wherein I have to create a log dataset containing 2 variables Error text and Error Timestamp. I want to populate this dataset anytime I run any SAS code. For Example, I ran a code and it hits an error, I want to populate the dataset with error text and timestamp. Next time, I again run the code and this time it runs sucessfully, I want to populate the dataset with Error text as sucessfull.&lt;/P&gt;&lt;P&gt;I though of exporting SAS logs to text file and then importing that file to a dataset, but I want somewhat of a realtime approach where that log dataset keeps on updating with each code run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if any more information is needed.&lt;/P&gt;&lt;P&gt;I am using SAS Studio&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2019 21:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594369#M170752</guid>
      <dc:creator>SAS_L</dc:creator>
      <dc:date>2019-10-06T21:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a SAS Dataset basis SAS code run result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594380#M170759</link>
      <description>&lt;P&gt;Create a little macro that inserts the error message into the data set. Add triggers into your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How that %IF/%THEN is structured will vary from program to program, but hopefully gives you an idea.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro add_error(error_code = , error_message = );

proc sql;
insert into mydb.Error_Log
values(&amp;amp;error_code, &amp;amp;error_message);
quit;

%mend;

proc sql;
create table test as
select name, weight, height, error
from sashelp.class;
quit;

%if _SYSERR_ %then %add_error("Mistake1", "Check program at Part2");

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Oct 2019 22:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594380#M170759</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-06T22:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a SAS Dataset basis SAS code run result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594408#M170766</link>
      <description>&lt;P&gt;I'm not a great fan of coding for job monitoring. You can get useful, but simple results by switching to running your code in SAS batch jobs via a job scheduler. The&amp;nbsp;scheduler can automatically email you to tell you if a job was successful or not. Or you can monitor with the scheduler dashboard. Scheduling is as easy as clicking on selections in SAS Management Console.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the SAS option SYNTAXCHECK is set by default in batch mode and will immediately throw a job into syntax check mode when it hits an error so you only ever need to search for the first error in the job. That is pretty easy just with a text search as each batch job produces a SAS log file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Read about this option here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lesysoptsref&amp;amp;docsetTarget=n014qbvh3po8w5n1qlqbzr22vtg0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lesysoptsref&amp;amp;docsetTarget=n014qbvh3po8w5n1qlqbzr22vtg0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 02:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/594408#M170766</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-07T02:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a SAS Dataset basis SAS code run result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/595239#M171203</link>
      <description>Thank You. I was able to use some part of this code in my solution and get it to work. Appreciate your help!</description>
      <pubDate>Thu, 10 Oct 2019 02:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-SAS-Dataset-basis-SAS-code-run-result/m-p/595239#M171203</guid>
      <dc:creator>SAS_L</dc:creator>
      <dc:date>2019-10-10T02:27:04Z</dc:date>
    </item>
  </channel>
</rss>

