<?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 test end of line error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19113#M2929</link>
    <description>I'm reading formated input, which is delimited by a '|', and each column is truncated to the length of the string in it. I don't have a clue about lrecl before actually reading the data.&lt;BR /&gt;
&lt;BR /&gt;
my data is more or less like this:&lt;BR /&gt;
&lt;BR /&gt;
row 1: aaa | 1 | bb | cccc | 22&lt;BR /&gt;
row 2: aa | 23 | b | ccc | 345&lt;BR /&gt;
row 3: a | 4 | bbb | cccc&lt;BR /&gt;
&lt;BR /&gt;
I want to catch the missing column in row 3 and send it to errors.&lt;BR /&gt;
Unless i'm missing something i think your solution doesn't apply to my case.</description>
    <pubDate>Tue, 19 Oct 2010 16:22:28 GMT</pubDate>
    <dc:creator>dropez</dc:creator>
    <dc:date>2010-10-19T16:22:28Z</dc:date>
    <item>
      <title>How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19111#M2927</link>
      <description>Hi there.&lt;BR /&gt;
&lt;BR /&gt;
I am reading a DB2 log file into SAS and want to make some error testing in order to validate the data i'm reading.&lt;BR /&gt;
One error i would like to catch but don't know how is when i try to read more data than what realy comes in each row of the log file.&lt;BR /&gt;
For example, reading var1-var5 in a row of data with only four variables.&lt;BR /&gt;
None of the infile options (flowover, missover, truncover, stopover, etc) suits me has i don't want to stop the process if that kind of error is found neither i want to ignore and set the values to missing or jump through the next line (flowover). I would like to output each of this error rows to an error dataset for further analysis and the valid ones to other(s) to continue processing.&lt;BR /&gt;
I tried checking _error_ after each input but seems that in this case scenario _error_ is always set to 0 unless the stopover option is active, which works kind of like errorabend, stoping the process imediatly.&lt;BR /&gt;
&lt;BR /&gt;
Any sugestions?&lt;BR /&gt;
&lt;BR /&gt;
Best regards,&lt;BR /&gt;
Pedro.</description>
      <pubDate>Tue, 19 Oct 2010 14:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19111#M2927</guid>
      <dc:creator>dropez</dc:creator>
      <dc:date>2010-10-19T14:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19112#M2928</link>
      <description>My limited testing indicates with MISSOVER and PAD infile statement options when the line is shorter than expected the value assigned to COLUMN= variable is LRECL+1.  For example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
1044  filename FT15F001 temp lrecl=64;&lt;BR /&gt;
1045  data _null_;&lt;BR /&gt;
1046     infile FT15F001 missover pad column=c;&lt;BR /&gt;
1047     input a;&lt;BR /&gt;
1048     put _all_;&lt;BR /&gt;
1049     parmcards;&lt;BR /&gt;
1054  ;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile FT15F001 is:&lt;BR /&gt;
      (system-specific pathname),&lt;BR /&gt;
      (system-specific file attributes)&lt;BR /&gt;
&lt;BR /&gt;
c=10 a=1 _ERROR_=0 _N_=1&lt;BR /&gt;
c=3 a=2 _ERROR_=0 _N_=2&lt;BR /&gt;
c=65 a=. _ERROR_=0 _N_=3&lt;BR /&gt;
c=5 a=3 _ERROR_=0 _N_=4&lt;BR /&gt;
NOTE: 4 records were read from the infile (system-specific pathname).&lt;BR /&gt;
      The minimum record length was 0.&lt;BR /&gt;
      The maximum record length was 8.&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
filename FT15F001 temp lrecl=64;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   infile FT15F001 missover pad column=c;&lt;BR /&gt;
   input a;&lt;BR /&gt;
   put _all_;&lt;BR /&gt;
   parmcards;&lt;BR /&gt;
       1&lt;BR /&gt;
2&lt;BR /&gt;
&lt;BR /&gt;
  3&lt;BR /&gt;
;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 19 Oct 2010 15:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19112#M2928</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-19T15:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19113#M2929</link>
      <description>I'm reading formated input, which is delimited by a '|', and each column is truncated to the length of the string in it. I don't have a clue about lrecl before actually reading the data.&lt;BR /&gt;
&lt;BR /&gt;
my data is more or less like this:&lt;BR /&gt;
&lt;BR /&gt;
row 1: aaa | 1 | bb | cccc | 22&lt;BR /&gt;
row 2: aa | 23 | b | ccc | 345&lt;BR /&gt;
row 3: a | 4 | bbb | cccc&lt;BR /&gt;
&lt;BR /&gt;
I want to catch the missing column in row 3 and send it to errors.&lt;BR /&gt;
Unless i'm missing something i think your solution doesn't apply to my case.</description>
      <pubDate>Tue, 19 Oct 2010 16:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19113#M2929</guid>
      <dc:creator>dropez</dc:creator>
      <dc:date>2010-10-19T16:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19114#M2930</link>
      <description>My solution would not work because with a delimiter other than BLANK you would need a trailing delimiter.&lt;BR /&gt;
&lt;BR /&gt;
Why can't you just use MISSOVER if the i'th variable is missing your record is short.&lt;BR /&gt;
&lt;BR /&gt;
Or you could use the _INFILE_ variable and count delimiters if the number don't suit ya, then take some action.</description>
      <pubDate>Tue, 19 Oct 2010 16:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19114#M2930</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-19T16:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19115#M2931</link>
      <description>I realy need to catch this kind of errors in order to ensure the DW consistency.&lt;BR /&gt;
I receive a pair of files each day, one being the DB2 log file and the other the DB2 structure at the time the log file was produced.&lt;BR /&gt;
Reading something different than what the structure file indicates means one of two things:&lt;BR /&gt;
1- The structure file is damaged.&lt;BR /&gt;
2- The log file is damaged.&lt;BR /&gt;
&lt;BR /&gt;
Neither one of this two options can be ignored as it will result in corrupting de DW.&lt;BR /&gt;
I could just use STOPOVER option but that would delay the processing of hundreds of tables just because one single row and that is what i want to avoid.&lt;BR /&gt;
&lt;BR /&gt;
I'll look if the _INFILE_ option suits my needs.</description>
      <pubDate>Tue, 19 Oct 2010 17:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19115#M2931</guid>
      <dc:creator>dropez</dc:creator>
      <dc:date>2010-10-19T17:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19116#M2932</link>
      <description>To the OP:  you really need to share the exact SAS code being used to read the DB2 log data (an external data file) - also info about where the external data file "originates" and equally important where the external file "resides" when you are accessing it from your SAS program.&lt;BR /&gt;
&lt;BR /&gt;
With variable-length data records, you have an INFORMAT $VARYINGnnn.  which may be suitable, but we really need to see exactly what you're working with -- hence the need for you to post in a reply, the SAS-generated LOG (DATA STEP) where you are attempting your external data input handling.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 19 Oct 2010 19:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19116#M2932</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-10-19T19:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19117#M2933</link>
      <description>Very simplified sample:&lt;BR /&gt;
...&lt;BR /&gt;
filename list pipe "ls -1 /stagingDelta/ftrans/LOGDB2*";&lt;BR /&gt;
...&lt;BR /&gt;
infile indata truncover;&lt;BR /&gt;
input iteminlist $100.;&lt;BR /&gt;
item=iteminlist;&lt;BR /&gt;
infile dummy filevar=item end=done dlm='|' dsd lrecl=10000;&lt;BR /&gt;
do while(^done);&lt;BR /&gt;
input &lt;B&gt;col1-col&amp;amp;colnumber $;&lt;/B&gt;&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;colnumber is built based on the information on the structure file mentioned before!&lt;BR /&gt;
&lt;BR /&gt;
I just want to know if it is possible to catch the "error" LOST CARD while processing, not loosing the CARD, but putting it to some kind of quarenteen and continue processing. I do not want no MISSOVER or TRUNCOVER, neither i want to stop all the process just because of one row (STOPOVER).&lt;BR /&gt;
If there are less columns than it's supposed in that row, if instead of having &amp;amp;colnumber columns i have only &amp;amp;colnumber-1, i want to be able to catch it.&lt;BR /&gt;
I am not able to know the lrecl of the row as each row as a different length, even if it is about the same table, which isn't a problem since my log file comes delimited by "|" &lt;BR /&gt;
As i explained before, i have a log file (.txt) with all the inserts, deletes and updates that took place in DB2, in the same machine where my sas program is running. Along with that log file comes a structure file containing the definition of each table that comes in the log file (number of variables, each variable length, type, integrity constraints, keys, etc).&lt;BR /&gt;
If that structure file tells me that i have to read 10 variables in each row of the log file for that table then i really need to do so, or else one of the two files is damaged and some manual work has to be done.&lt;BR /&gt;
The problem is i can't seem to catch an error when SAS reads less information than it is supposed to. If i tell the script to read 10 variables but there are only 9 in that row the only way i can identify that is by setting the STOPOVER option in the filename statement, which imediatly stops the process. I want to avoid stopping the process, else, put that/those row/s to some kind of quarenteen file and process the remainig log.</description>
      <pubDate>Wed, 20 Oct 2010 08:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19117#M2933</guid>
      <dc:creator>dropez</dc:creator>
      <dc:date>2010-10-20T08:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19118#M2934</link>
      <description>&amp;gt; If i tell the script to read 10 variables but there are&lt;BR /&gt;
&amp;gt; only 9 in that row the only way i can identify that&lt;BR /&gt;
&lt;BR /&gt;
Count the delimiters.</description>
      <pubDate>Wed, 20 Oct 2010 12:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19118#M2934</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-20T12:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19119#M2935</link>
      <description>&amp;gt; infile dummy filevar=item end=done dlm='|' dsd&lt;BR /&gt;
&amp;gt; lrecl=10000;&lt;BR /&gt;
&amp;gt; do while(^done);&lt;BR /&gt;
&amp;gt; input &lt;B&gt;col1-col&amp;amp;colnumber $;&lt;/B&gt;&lt;BR /&gt;
&amp;gt; ...&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I just want to know if it is possible to catch the&lt;BR /&gt;
&amp;gt; "error" LOST CARD while processing, not loosing the&lt;BR /&gt;
&amp;gt; CARD, but putting it to some kind of quarenteen and&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
there is an infile option LENGTH= which names a variable which will be filled with the length of the "current" line&lt;BR /&gt;
there is also option COLUMN= which names a variable to hold the current column position on the input line (at which the next INPUT statement would read with no other positioning directive)&lt;BR /&gt;
You can read accross the line until the "next" position will be at the end of the line (FLOWOVER will need to be avoided)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; infile dummy filevar=item end=done dlm='|' dsd &lt;BR /&gt;
   col=col length=len truncover&lt;BR /&gt;
&amp;gt; lrecl=10000;&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; do while(^done);&lt;BR /&gt;
   array col(&amp;amp;colNumber) ; *** add $ if string not numeric*** ;&lt;BR /&gt;
   &lt;BR /&gt;
   input @1 @ ; ** position at start of input line ;&lt;BR /&gt;
&lt;BR /&gt;
   do col_number = 1 to &amp;amp;colnumber while(  col &amp;lt; len ) ;&lt;BR /&gt;
      input col(col_number) @  ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
   if col_number LT &amp;amp;col_number then do;&lt;BR /&gt;
     * report the problem ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
 &lt;BR /&gt;
 alternatively examine the number of delimiters in the _infile_ buffer&lt;BR /&gt;
(not good enough if the delimiter might be embedded in data, like in "erty|tyu" in:&lt;BR /&gt;
 2345|3456|"erty|tyu"|4567||  &lt;BR /&gt;
input @ ;&lt;BR /&gt;
n_delim = count ( _file_, '|'   );&lt;BR /&gt;
provides a count of the delimiters on the input line&lt;BR /&gt;
If that is always OK,&lt;BR /&gt;
then check the last 1 or 2 characters on the file buffer&lt;BR /&gt;
if substr( _file_, length( _file_ ),1) EQ '|' then do;&lt;BR /&gt;
   ***** report last column is empty ;&lt;BR /&gt;
end ;&lt;BR /&gt;
Alternative check if the last column is empty&lt;BR /&gt;
if scan( _file_, -1,'|' ) EQ ' ' then do;&lt;BR /&gt;
   ***** report last column is empty ;&lt;BR /&gt;
end ;&lt;BR /&gt;
if scan( _file_, -2,'|' ) EQ ' ' then do;&lt;BR /&gt;
   ***** report second last column is empty ;&lt;BR /&gt;
end ;</description>
      <pubDate>Wed, 20 Oct 2010 13:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19119#M2935</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-10-20T13:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to test end of line error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19120#M2936</link>
      <description>&amp;gt; alternatively examine the number of delimiters in&lt;BR /&gt;
&amp;gt;  the _infile_ buffer&lt;BR /&gt;
&amp;gt; not good enough if the delimiter might be embedded in&lt;BR /&gt;
&amp;gt; data, like in "erty|tyu" in:&lt;BR /&gt;
&amp;gt;  2345|3456|"erty|tyu"|4567||  &lt;BR /&gt;
&lt;BR /&gt;
How about counting the words.  &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
1951  filename FT15F001 temp;&lt;BR /&gt;
1952  canWeCountWords:&lt;BR /&gt;
1952!                  data _null_;&lt;BR /&gt;
1953     infile FT15F001;&lt;BR /&gt;
1954     input @;&lt;BR /&gt;
1955     c = countW(_infile_,'|','MQ');&lt;BR /&gt;
1956     put 'NOTE: ' c=;&lt;BR /&gt;
1957     list;&lt;BR /&gt;
1958     parmcards;&lt;BR /&gt;
1961  ;;;;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile FT15F001 is:&lt;BR /&gt;
      (system-specific pathname),&lt;BR /&gt;
      (system-specific file attributes)&lt;BR /&gt;
&lt;BR /&gt;
NOTE: c=6&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;
1         2345|3456|"erty|tyu"|4567|| 27&lt;BR /&gt;
NOTE: c=2&lt;BR /&gt;
2         | 1&lt;BR /&gt;
NOTE: 2 records were read from the infile (system-specific pathname).&lt;BR /&gt;
      The minimum record length was 1.&lt;BR /&gt;
      The maximum record length was 27.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 20 Oct 2010 16:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-test-end-of-line-error/m-p/19120#M2936</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-10-20T16:41:52Z</dc:date>
    </item>
  </channel>
</rss>

