<?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: Adding a row in a table when SAS DI job starts in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504351#M15659</link>
    <description>&lt;P&gt;You could use Status Handling feature in SAS DI Studio.&lt;/P&gt;
&lt;P&gt;Job -&amp;gt; Properties -&amp;gt; Status Handling Tab&lt;/P&gt;
&lt;P&gt;New -&amp;gt; Select a condition (Perhaps "Send Job Status")&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Action, select Custom&lt;/P&gt;
&lt;P&gt;For the Value of Action Options, add an insert statement with the macro variables you want in the output&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;proc sql; insert into MYLIB.MyStatus_handlingTable set message="&amp;amp;SYSUSERID &amp;amp;SYSJOBID", datetime="&amp;amp;SYSDATE &amp;amp;SYSTIME"; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Oct 2018 15:02:03 GMT</pubDate>
    <dc:creator>VenuKadari</dc:creator>
    <dc:date>2018-10-15T15:02:03Z</dc:date>
    <item>
      <title>Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504236#M15646</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a row in existing Oracle table when SAS DI job starts (job name, timedate started, user who ran it...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be a proper transformation to do so? Most of them expect input table and I really need only simple INSERT INTO .... statement (would like to avoid user written code if possible).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 09:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504236#M15646</guid>
      <dc:creator>strsljen</dc:creator>
      <dc:date>2018-10-15T09:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504266#M15649</link>
      <description>&lt;P&gt;Create a one-row table with your data from the existing oracle table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data append_table;
if 0 then set oracle_table; /* this gets us all the variable attributes */
name = "&amp;amp;jobname";
/* and so on */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use this table in an append transformation on the Oracle table.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 12:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504266#M15649</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-15T12:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504280#M15651</link>
      <description>&lt;P&gt;Since this is merely logging meta data I wouldn't necessarily create a transformation for it, since it doesn't tamper with the actual ETL data. So you could create a macro (assume you need this logging in several/all jobs), and call it from jobs pre-code, or even from SASBatchServer autoexec if you do it really generic...&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 13:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504280#M15651</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-10-15T13:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504331#M15658</link>
      <description>&lt;P&gt;Spooky!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Literally just wrote a macro for this, to go in the pre and post code of jobs (and nodes) to record "JobEvents" and log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;things like user, job name, flow name, pid, lsfJobID, LSFFlowID, timesmap, username, compute hostname, metadata hostname etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is to track job performance "mid-run" and also leverage things like the FlowID to allow multiple instances of the same flow to run happily synchronously, and to have a unique ID that is inherent across all jobs in the flow.&lt;/P&gt;
&lt;P&gt;Here's the table properties:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Job Events Table.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24018iCF44389B5924AE58/image-size/large?v=v2&amp;amp;px=999" role="button" title="Job Events Table.png" alt="Job Events Table.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Invocation is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%jobEvent(Event=Start) for example in the precode of the job, and&amp;nbsp;&lt;SPAN&gt;%jobEvent(Event=End) &lt;/SPAN&gt;in the post code,&lt;/P&gt;
&lt;P&gt;and perhaps&amp;nbsp;&lt;SPAN&gt;%jobEvent(Event=Start_Bulk_Load) and&amp;nbsp;%jobEvent(Event=End_Bulk_Load) in the pre and post code of a heavy ligting table loader, for example.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The idea is the Event field is structured/categorical, and the Narrative field allows for semi-structured content, maybe like loop iteration counts, row counts, file sizes and names etc.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 15:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504331#M15658</guid>
      <dc:creator>AngusLooney</dc:creator>
      <dc:date>2018-10-15T15:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504351#M15659</link>
      <description>&lt;P&gt;You could use Status Handling feature in SAS DI Studio.&lt;/P&gt;
&lt;P&gt;Job -&amp;gt; Properties -&amp;gt; Status Handling Tab&lt;/P&gt;
&lt;P&gt;New -&amp;gt; Select a condition (Perhaps "Send Job Status")&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Action, select Custom&lt;/P&gt;
&lt;P&gt;For the Value of Action Options, add an insert statement with the macro variables you want in the output&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;proc sql; insert into MYLIB.MyStatus_handlingTable set message="&amp;amp;SYSUSERID &amp;amp;SYSJOBID", datetime="&amp;amp;SYSDATE &amp;amp;SYSTIME"; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 15:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504351#M15659</guid>
      <dc:creator>VenuKadari</dc:creator>
      <dc:date>2018-10-15T15:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504354#M15660</link>
      <description>&lt;P&gt;Nice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mine is in effect slightly over engineered compared to that, but&amp;nbsp;it does quite a bit more, and allows for mid-job events as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It grew out of a need for access to the LSF attributes of a job,&amp;nbsp;the JobID and the FlowID of the instance of the flow the instance of the job is in, etc.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 15:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504354#M15660</guid>
      <dc:creator>AngusLooney</dc:creator>
      <dc:date>2018-10-15T15:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504355#M15661</link>
      <description>&lt;P&gt;Have to agree with you on User Written code (see my DI &lt;STRONG&gt;Worst&lt;/STRONG&gt; Practice in this Forum a few months ago), but a general purpose macro you can reuse is another matter.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 15:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504355#M15661</guid>
      <dc:creator>AngusLooney</dc:creator>
      <dc:date>2018-10-15T15:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504453#M15662</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153471"&gt;@AngusLooney&lt;/a&gt; Thanks for this presentation. Now I am sure I am not the only one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we ever meet f2f, beer is on me! &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;Trying to stop certain "influencers" in my company to convince the others that SAS DI is completely OK with bunch of User Written Code.&lt;/P&gt;&lt;P&gt;Even some SAS experts in the field (tbh, old school SAS coders tend to disrespect "modern graphical tools of the trade") think it's no&amp;nbsp; big deal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is. It would give us nightmare in maintenance later and I am fighting very hard against it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for my original question, macro function might be a nice and clean solution. Good advice! Unfortunately, I am far from expert in writing SAS macro functions. Will try to get help or it will really take time. &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;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504453#M15662</guid>
      <dc:creator>strsljen</dc:creator>
      <dc:date>2018-10-15T19:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504610#M15666</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166915"&gt;@strsljen&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If you're using a macro then I'd implement this macro as a custom transformation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally "hate" pre- and post-code as it doesn't show in the job flow. So I rather have a custom transformation which I just place into my jobs wherever I need it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally tend to implement by having the macro in an Autocall library and only have the macro call in the custom transformation as this allows me to eventually change macro code in a single place without the need to redeploy all the jobs using the custom transformation.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 07:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504610#M15666</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-16T07:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a row in a table when SAS DI job starts</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504651#M15672</link>
      <description>&lt;P&gt;Definitely a fan&amp;nbsp;of autocall macros, though there are pros and cons that are worth discussing at some point, wrt DI jobs etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing I really like about them is that you get the best of both worlds, you can use them in code AND in User Transforms, simultaneously without loss of control. I would suggest that best practice (or at least very good practice) is to treat UT as merely the &lt;STRONG&gt;design-time&lt;/STRONG&gt; UI for calls to autocall macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Taking this approach, there's no reason &lt;STRONG&gt;not&lt;/STRONG&gt; to use an explicit UT to host the calls to the likes of jobEvent, rather than putting the call into pre/post code route.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you say, that avoids functionality being "hidden", and essentially, would be no less "efficient" (don't get me started on the over-obsession with "efficiency"), and you are sticking to the "it's obvious" principle,&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 09:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Adding-a-row-in-a-table-when-SAS-DI-job-starts/m-p/504651#M15672</guid>
      <dc:creator>AngusLooney</dc:creator>
      <dc:date>2018-10-16T09:46:53Z</dc:date>
    </item>
  </channel>
</rss>

