<?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: different results when input disk external file and in-stream data lines using infile in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/different-results-when-input-disk-external-file-and-in-stream/m-p/566489#M159217</link>
    <description>&lt;P&gt;SAS will pad in-line data records to an exact multiple of 80 characters (card images).&amp;nbsp; That is why the behave differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the real issue is that your INPUT statement is wrong.&amp;nbsp; You are asking it to read EXACTLY five characters. If the line is shorter than five characters long (or has less than five character left before the end-of-line) then the INPUT statement will throw away those characters and move to the next file to find something that will satisfy what you wanted.&amp;nbsp; Fortunately it only moves to the next line once (or else you would only get two observations).&amp;nbsp; So the first two iterations of your data step both consume two lines from your text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could add the TRUNCOVER option to the INFILE statement to change how it behaves when there are not enough characters on the line to satisfy the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or change the INPUT statement so it will not try to read so many characters.&amp;nbsp; You could use LIST mode.&amp;nbsp; Either by removing the informat (SAS does need special instructions for reading normal numbers).&amp;nbsp; Or adding the : modifier before the informat specification.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2019 03:38:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-17T03:38:17Z</dc:date>
    <item>
      <title>different results when input disk external file and in-stream data lines using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/different-results-when-input-disk-external-file-and-in-stream/m-p/566486#M159214</link>
      <description>&lt;P&gt;I use input and infile statements with option&amp;nbsp; in data step to input external data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In first case, the external data are in-stream data lines and the code are&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;input num 5.;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;BR /&gt;22&lt;BR /&gt;333&lt;BR /&gt;4444&lt;BR /&gt;5555&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;tes1 has three observations,&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;333&lt;/P&gt;&lt;P&gt;4444&lt;/P&gt;&lt;P&gt;55555&lt;/P&gt;&lt;P&gt;In Second case ,the external data is&amp;nbsp; in d:\mydata\x.txt and&amp;nbsp; and the code are&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;infile 'd:\mydata\x.txt' missover;&lt;BR /&gt;input num 5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;test has its observation as following&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;5555&lt;/P&gt;&lt;P&gt;which is different from those in test1 completely. Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 03:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/different-results-when-input-disk-external-file-and-in-stream/m-p/566486#M159214</guid>
      <dc:creator>Steve1964</dc:creator>
      <dc:date>2019-06-17T03:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: different results when input disk external file and in-stream data lines using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/different-results-when-input-disk-external-file-and-in-stream/m-p/566489#M159217</link>
      <description>&lt;P&gt;SAS will pad in-line data records to an exact multiple of 80 characters (card images).&amp;nbsp; That is why the behave differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the real issue is that your INPUT statement is wrong.&amp;nbsp; You are asking it to read EXACTLY five characters. If the line is shorter than five characters long (or has less than five character left before the end-of-line) then the INPUT statement will throw away those characters and move to the next file to find something that will satisfy what you wanted.&amp;nbsp; Fortunately it only moves to the next line once (or else you would only get two observations).&amp;nbsp; So the first two iterations of your data step both consume two lines from your text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could add the TRUNCOVER option to the INFILE statement to change how it behaves when there are not enough characters on the line to satisfy the INPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or change the INPUT statement so it will not try to read so many characters.&amp;nbsp; You could use LIST mode.&amp;nbsp; Either by removing the informat (SAS does need special instructions for reading normal numbers).&amp;nbsp; Or adding the : modifier before the informat specification.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 03:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/different-results-when-input-disk-external-file-and-in-stream/m-p/566489#M159217</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-17T03:38:17Z</dc:date>
    </item>
  </channel>
</rss>

