<?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: Reading a variable length file in Mainframe in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275891#M55234</link>
    <description>I run SAS on MF platform and want to have the script for regular formatting of the VB file. &lt;BR /&gt;&lt;BR /&gt;I have difficulty in writing a DATA step to read a VB Mainframe file. Once I;m able to do it, I can get the further processing ....</description>
    <pubDate>Wed, 08 Jun 2016 07:46:28 GMT</pubDate>
    <dc:creator>AnalystKumar</dc:creator>
    <dc:date>2016-06-08T07:46:28Z</dc:date>
    <item>
      <title>Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275885#M55232</link>
      <description>&lt;P&gt;Hi SAS Expert Team,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I have a query reading the large VB file in Mainframes. File specs are below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File length = 11504&lt;/P&gt;
&lt;P&gt;File Type = VB (Variable block)&lt;/P&gt;
&lt;P&gt;Contains Records with variable length. &amp;nbsp;Example : If record 1 have the length of 765, then the rest of the characters in the observation 1 are null values. At position, 766 there will be CRLF that will specify the end of the observation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the obseravations start with the date in the format 'YYYYMMDD' format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many instances, thre is a need to filter data on basis of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;gt; DATE in the first 8 characters and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;gt; customer-id placed randomly in the observation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;gt; Invoice Number placed at the fixed position of 65.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I write a DATA step to read a Mainframe VB file and&amp;nbsp;create sub-file based on the criteria.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Kumar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 07:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275885#M55232</guid>
      <dc:creator>AnalystKumar</dc:creator>
      <dc:date>2016-06-08T07:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275888#M55233</link>
      <description>&lt;P&gt;Do you run SAS on the mainframe or another platform?&lt;/P&gt;
&lt;P&gt;If another platform, do you have direct FTP access to the MF or do you receive the file via another path?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 07:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275888#M55233</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-08T07:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275891#M55234</link>
      <description>I run SAS on MF platform and want to have the script for regular formatting of the VB file. &lt;BR /&gt;&lt;BR /&gt;I have difficulty in writing a DATA step to read a VB Mainframe file. Once I;m able to do it, I can get the further processing ....</description>
      <pubDate>Wed, 08 Jun 2016 07:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275891#M55234</guid>
      <dc:creator>AnalystKumar</dc:creator>
      <dc:date>2016-06-08T07:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275894#M55235</link>
      <description>&lt;P&gt;So, how far have you come already?&lt;/P&gt;
&lt;P&gt;Did you have problems with the &lt;A href="http://support.sas.com/documentation/cdl/en/hosto390/65144/HTML/default/viewer.htm#p06y69omp86scmn1i9nvllynndga.htm" target="_blank"&gt;INFILE statement on z/OS&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 07:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275894#M55235</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-08T07:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275897#M55236</link>
      <description>Yes, I made little progress.&lt;BR /&gt;&lt;BR /&gt;DATE FILEOUT;&lt;BR /&gt;INFILE FILEIN1 LENGTH=LINELEN  LRECL=11504 PAD;        &lt;BR /&gt;INPUT VAR1 $1  &lt;BR /&gt;            DATE_VAR $8 @;   /* ASSIGN THE LENGTH */&lt;BR /&gt;VARLEN=LINELEN - 9;                                 &lt;BR /&gt;INPUT @10 REST_STRING $VARYING10991. VARLEN;         &lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA=FILEOUT;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;One more point I forgot to mention is that , CRLF exists in many parts of the message, But actual end of the record (or observation is)  double-star **. &lt;BR /&gt;&lt;BR /&gt;With the above DATE Step, data reads only until the first CRLF in the observations and then discards from there. Jumping on to the next line.</description>
      <pubDate>Wed, 08 Jun 2016 08:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275897#M55236</guid>
      <dc:creator>AnalystKumar</dc:creator>
      <dc:date>2016-06-08T08:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275901#M55237</link>
      <description>&lt;P&gt;The first thing I'd try would be the RECFM=VB option in the infile statement. For VB files, z/OS maintains a separate 4-byte RDW (record descriptor word) that holds the current record length in its first two bytes. This eliminates the need for record separators.&lt;/P&gt;
&lt;P&gt;Omitting the RECFM= options forces SAS to use any CRLF or similar combination (LF only, eg) as a record separator.&lt;/P&gt;
&lt;P&gt;With RECVM=VB, you should not have line skips when a CRLF is encountered in the data.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 08:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275901#M55237</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-08T08:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275911#M55243</link>
      <description>No Luck,   &lt;BR /&gt;&lt;BR /&gt;I have added RECFM=VB option on the DATA step. But still the observations get skips when it encounters a first CRLF</description>
      <pubDate>Wed, 08 Jun 2016 09:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275911#M55243</guid>
      <dc:creator>AnalystKumar</dc:creator>
      <dc:date>2016-06-08T09:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275912#M55244</link>
      <description>I see the warning message in the log. &lt;BR /&gt;WARNING: Data too long for column "REST_STRING"; truncated to 128 characters to&lt;BR /&gt;&lt;BR /&gt;before and after adding the RECFM=VB option&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Jun 2016 09:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275912#M55244</guid>
      <dc:creator>AnalystKumar</dc:creator>
      <dc:date>2016-06-08T09:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a variable length file in Mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275922#M55249</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fileout;
infile filein1 recfm=vb lrecl=11504 truncover;
input
  var1 $1.
  date_var $8.
  rest_string $11493.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that doesn't fix your CRLF problem, you need to have those CRLFs stripped before you read into SAS.&lt;/P&gt;
&lt;P&gt;Alternatively you could try to read with recfm=n (this reads the input as a non-formatted stream), read chunks of, say, 100 bytes into a large buffer until you find the line-delimiting '**' in your buffer, and work data out of the buffer. Then start reading again until you encounter the next '**' or EOF.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 10:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-variable-length-file-in-Mainframe/m-p/275922#M55249</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-08T10:50:27Z</dc:date>
    </item>
  </channel>
</rss>

