<?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 Infile statement omits first line from XML file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566121#M159055</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have a problem with infile statement, it's very basic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename fin "&amp;amp;_we." encoding=utf8 lrecl=10000; &lt;BR /&gt;filename fout "&amp;amp;_wy." encoding=utf8 lrecl=10000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data res;&lt;/P&gt;
&lt;P&gt;length oneline $10000;&lt;/P&gt;
&lt;P&gt;infile fin dlm='****' encoding=utf8;&lt;/P&gt;
&lt;P&gt;file fout encoding=utf8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;input oneline $10000. @@;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately it omits the first line from XML file.&lt;BR /&gt;&lt;BR /&gt;Do you have any idea why?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 07:01:02 GMT</pubDate>
    <dc:creator>Dontik</dc:creator>
    <dc:date>2019-06-14T07:01:02Z</dc:date>
    <item>
      <title>Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566121#M159055</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have a problem with infile statement, it's very basic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename fin "&amp;amp;_we." encoding=utf8 lrecl=10000; &lt;BR /&gt;filename fout "&amp;amp;_wy." encoding=utf8 lrecl=10000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data res;&lt;/P&gt;
&lt;P&gt;length oneline $10000;&lt;/P&gt;
&lt;P&gt;infile fin dlm='****' encoding=utf8;&lt;/P&gt;
&lt;P&gt;file fout encoding=utf8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;input oneline $10000. @@;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately it omits the first line from XML file.&lt;BR /&gt;&lt;BR /&gt;Do you have any idea why?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 07:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566121#M159055</guid>
      <dc:creator>Dontik</dc:creator>
      <dc:date>2019-06-14T07:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566124#M159056</link>
      <description>&lt;P&gt;You define your filenames with variable record lengths, and then force-read 10000 bytes. If the first line is less than that in length, SAS will set the variable to missing and skip to the next line. Use the truncover option in the infile statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What kind of XML file are you reading?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 08:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566124#M159056</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-14T08:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566128#M159058</link>
      <description>"TRUNCOVER enables you to read variable-length records when some records are shorter than the INPUT statement expects. Variables without any values assigned are set to missing."&lt;BR /&gt;&lt;BR /&gt;Thank you, that makes sense, unfortunately using truncover makes infile statement very slow.. In fact, 10 minutes later it's still running..&lt;BR /&gt;&lt;BR /&gt;What do you want to know about my XML file?</description>
      <pubDate>Fri, 14 Jun 2019 08:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566128#M159058</guid>
      <dc:creator>Dontik</dc:creator>
      <dc:date>2019-06-14T08:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566147#M159064</link>
      <description>&lt;P&gt;Double trailing AT&amp;nbsp;@@ and truncover are causing infinite loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28124"&gt;@Dontik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;"TRUNCOVER enables you to read variable-length records when some records are shorter than the INPUT statement expects. Variables without any values assigned are set to missing."&lt;BR /&gt;&lt;BR /&gt;Thank you, that makes sense, unfortunately using truncover makes infile statement very slow.. In fact, 10 minutes later it's still running..&lt;BR /&gt;&lt;BR /&gt;What do you want to know about my XML file?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 11:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566147#M159064</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-06-14T11:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566155#M159067</link>
      <description>&lt;P&gt;Yeah, the truncover and @@ will cause problems. Good catch of my foul ball, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;Try to get a feel for your infile.&lt;/P&gt;
&lt;P&gt;Do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile fileref end=eof;
retain maxlen 0;
maxlen = max(maxlen,length(_infile_));
if eof then do;&lt;BR /&gt;  call symputx('maxlen',maxlen);&lt;BR /&gt;  call symputx('recnum',_n_);&lt;BR /&gt;end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to see how large your lines are and how many you have to read.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 12:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566155#M159067</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-14T12:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Infile statement omits first line from XML file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566165#M159071</link>
      <description>&lt;P&gt;It is skipping the first line because you asked SAS to read 1000 bytes. If the first line doesn't have enough characters then the INPUT statement will flow to the next line and read from there instead.&lt;/P&gt;
&lt;P&gt;Using formatted input with double trailing&amp;nbsp;@ does not seem right.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your variable names make it look like you want to read the data line by line. So just use TRUNCOVER option on INFILE and remove the trailing&amp;nbsp;@@.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data res;
  length oneline $10000;
  infile fin dlm='****' encoding=utf8 truncover;
  file fout encoding=utf8;
  input oneline $10000. ;
  put oneline;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use a bare INPUT statement and copy the text of the line form the automatic variable _INFILE_.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data res;
  infile fin dlm='****' encoding=utf8 truncover;
  file fout encoding=utf8;
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to read that data term by term then use list mode input instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data res;
  length oneword $10000;
  infile fin dlm='****' encoding=utf8 ;
  file fout encoding=utf8;
  input oneword @@ ;
  put oneword @;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also why are you using * as your delimiter character (default is space)? And then why do you list if four times?&amp;nbsp; If you want to use four * next to each other as the delimiter then you need to use DLMSTR= option instead of DLM= option. When you list multiple characters in the DLM= option each one is treated as a possible delimiter.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 13:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-statement-omits-first-line-from-XML-file/m-p/566165#M159071</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-14T13:02:58Z</dc:date>
    </item>
  </channel>
</rss>

