<?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 capture rejected records? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49441#M10259</link>
    <description>Hi data _null_&lt;BR /&gt;
&lt;BR /&gt;
SCD2: That's mainly nothing else than a loading technique where you keep all the history records in the same table - which means that these tables tend to grow.&lt;BR /&gt;
&lt;A href="http://en.wikipedia.org/wiki/Slowly_changing_dimension" target="_blank"&gt;http://en.wikipedia.org/wiki/Slowly_changing_dimension&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Less of an issue if someone uses a data base like Oracle where a table can be partitioned; more of an issue with SAS files where a table is just one big file.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
You really pushed me into the right direction. I think I found everything I need in the docu:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a001224397.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a001224397.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As I have to use SAS DI Studio in the project I am the only option will be to use an audit trail.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
That's the approach I have in mind:&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
   audit want;&lt;BR /&gt;
      initiate ;&lt;BR /&gt;
      LOG &lt;BR /&gt;
        BEFORE_IMAGE=NO &lt;BR /&gt;
        DATA_IMAGE=NO&lt;BR /&gt;
        ERROR_IMAGE=YES; &lt;BR /&gt;
      run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc append base=want data=have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data error_yymmdd;&lt;BR /&gt;
  set want(type=audit keep=id _:);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
   audit want;&lt;BR /&gt;
      TERMINATE ;&lt;BR /&gt;
      run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For the ones using DI Studio 4.2: &lt;BR /&gt;
I'm thinking about implementing the part before the PROC APPEND as pre-code in the SCD2 loader, and the part after the PROC APPEND as post-code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
    <pubDate>Wed, 14 Jul 2010 15:24:38 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2010-07-14T15:24:38Z</dc:date>
    <item>
      <title>How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49434#M10252</link>
      <description>Hi all&lt;BR /&gt;
&lt;BR /&gt;
Loading data into a SAS table with integrity constraints (SAS 9.2, Windows 64bit):&lt;BR /&gt;
Is there a way how I could capture rejected records and write them to an error table?&lt;BR /&gt;
&lt;BR /&gt;
In the example below: How would I capture the rejected record and write it to an error table?&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
  do id=1 to 3;&lt;BR /&gt;
    var='A';&lt;BR /&gt;
    if id=2 then var='';&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  stop;&lt;BR /&gt;
  set have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
  modify want;&lt;BR /&gt;
    ic create not null(var);&lt;BR /&gt;
  run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc append base=want data=have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Real world:&lt;BR /&gt;
The amount of data I'm dealing with is considerable so I try to avoid merging source and target data after loading in order to get the rejected delta.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 14 Jul 2010 13:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49434#M10252</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-14T13:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49435#M10253</link>
      <description>I have no idea what your data step creating data set HAVE is doing. it looks like you are using a loop over three ids to create a one record where id=2 and var='' and the other records have var='A'. Totally meaningless example to me, and I can't understand what the rejected records are that you are discussing.&lt;BR /&gt;
&lt;BR /&gt;
Clarifications would be helpful.</description>
      <pubDate>Wed, 14 Jul 2010 13:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49435#M10253</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-07-14T13:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49436#M10254</link>
      <description>You will need AUDIT.  There are a number of options that you will need to decide about but this should get you started.  See PROC DATASETS documentation.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
   modify want;&lt;BR /&gt;
      ic create not null(var);&lt;BR /&gt;
      run;&lt;BR /&gt;
   audit want;&lt;BR /&gt;
      initiate;&lt;BR /&gt;
      run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc append base=want data=have;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=want(type=audit);&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 14 Jul 2010 13:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49436#M10254</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-07-14T13:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49437#M10255</link>
      <description>Paige&lt;BR /&gt;
&lt;BR /&gt;
The question was meant for people who might know...&lt;BR /&gt;
&lt;BR /&gt;
But for you some more explanation.&lt;BR /&gt;
&lt;BR /&gt;
/* create example source table with 3 records */&lt;BR /&gt;
data have;&lt;BR /&gt;
  do id=1 to 3;&lt;BR /&gt;
    var='A';&lt;BR /&gt;
    if id=2 then var='';&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* create target table: mapping step */&lt;BR /&gt;
data want;&lt;BR /&gt;
  stop;&lt;BR /&gt;
  set have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* add NOT NULL integrity constraint to target table */&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
  modify want;&lt;BR /&gt;
    ic create not null(var);&lt;BR /&gt;
  run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
/* load source into target */&lt;BR /&gt;
proc append base=want data=have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* print resulting target table */&lt;BR /&gt;
proc print data=want;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Only the first and third record got loaded into the target table.&lt;BR /&gt;
&lt;BR /&gt;
The second record has been rejected due to the NOT NULL constraint on variable "var".&lt;BR /&gt;
&lt;BR /&gt;
The following can be seen in the log:&lt;BR /&gt;
WARNING: Add/Update failed for data set WORK.WANT because data value(s) do not comply with integrity&lt;BR /&gt;
         constraint _NM0001_. (Occurred 1 times.)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 14 Jul 2010 13:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49437#M10255</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-14T13:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49438#M10256</link>
      <description>Data _null_&lt;BR /&gt;
&lt;BR /&gt;
Once more thanks a lot. ...and you definitly wrote this code on a Unix machine (no CR).&lt;BR /&gt;
&lt;BR /&gt;
An audit trail on a SCD2 table with millions of records - scary!&lt;BR /&gt;
&lt;BR /&gt;
Follow up question:&lt;BR /&gt;
Has anybody experience with what that will do to performance?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 14 Jul 2010 14:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49438#M10256</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-14T14:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49439#M10257</link>
      <description>&amp;gt; Once more thanks a lot. ...and you definitly wrote&lt;BR /&gt;
&amp;gt; this code on a Unix machine (no CR).&lt;BR /&gt;
&lt;BR /&gt;
No windows the pre and /pre directives cause the loss of CR.  I paste to WORD then copy to my editor, when I copy code from this forum.&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; An audit trail on a SCD2 table with millions of&lt;BR /&gt;
&amp;gt; records - scary!&lt;BR /&gt;
&lt;BR /&gt;
Don't know what that is?  You can limit the amount of output written to the AUDIT file.  &lt;BR /&gt;
&lt;BR /&gt;
[pre]log data_image=NO before_image=NO;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
You might try a different approcah using the MODIFY statement.  Just send all rejected records to a BAD file.  I don't know if it is possible to know which IC the record was rejected for as with AUDIT.  Still might be adequate for your needs.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data want bad;&lt;BR /&gt;
   if 0 then modify want;&lt;BR /&gt;
   set have;&lt;BR /&gt;
   output want;&lt;BR /&gt;
   if _iorc_ ne 0 then output bad;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 14 Jul 2010 14:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49439#M10257</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-07-14T14:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49440#M10258</link>
      <description>data have reject;&lt;BR /&gt;
do id=1 to 3;&lt;BR /&gt;
if id=2 then output have;&lt;BR /&gt;
else output reject;&lt;BR /&gt;
end;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 14 Jul 2010 15:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49440#M10258</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-07-14T15:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to capture rejected records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49441#M10259</link>
      <description>Hi data _null_&lt;BR /&gt;
&lt;BR /&gt;
SCD2: That's mainly nothing else than a loading technique where you keep all the history records in the same table - which means that these tables tend to grow.&lt;BR /&gt;
&lt;A href="http://en.wikipedia.org/wiki/Slowly_changing_dimension" target="_blank"&gt;http://en.wikipedia.org/wiki/Slowly_changing_dimension&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Less of an issue if someone uses a data base like Oracle where a table can be partitioned; more of an issue with SAS files where a table is just one big file.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
You really pushed me into the right direction. I think I found everything I need in the docu:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a001224397.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/en/lrcon/62955/HTML/default/a001224397.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
As I have to use SAS DI Studio in the project I am the only option will be to use an audit trail.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
That's the approach I have in mind:&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
   audit want;&lt;BR /&gt;
      initiate ;&lt;BR /&gt;
      LOG &lt;BR /&gt;
        BEFORE_IMAGE=NO &lt;BR /&gt;
        DATA_IMAGE=NO&lt;BR /&gt;
        ERROR_IMAGE=YES; &lt;BR /&gt;
      run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc append base=want data=have;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data error_yymmdd;&lt;BR /&gt;
  set want(type=audit keep=id _:);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc datasets lib=work nolist;&lt;BR /&gt;
   audit want;&lt;BR /&gt;
      TERMINATE ;&lt;BR /&gt;
      run;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For the ones using DI Studio 4.2: &lt;BR /&gt;
I'm thinking about implementing the part before the PROC APPEND as pre-code in the SCD2 loader, and the part after the PROC APPEND as post-code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 14 Jul 2010 15:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-capture-rejected-records/m-p/49441#M10259</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-07-14T15:24:38Z</dc:date>
    </item>
  </channel>
</rss>

