<?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 data from file - issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350388#M81434</link>
    <description>Good catch, Art! I completely spaced out on TRUNCOVER.&lt;BR /&gt;cynthia</description>
    <pubDate>Sun, 16 Apr 2017 19:50:30 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2017-04-16T19:50:30Z</dc:date>
    <item>
      <title>Reading data from file - issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350377#M81430</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Mismatch in field picked from file while reading in data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;FILENAME trans6'/folders/myfolders/transaction_date.txt';&lt;/P&gt;&lt;P&gt;data trans6;&lt;BR /&gt;infile trans6;&lt;BR /&gt;input @1 trans_date mmddyy10.&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70859"&gt;@12&lt;/a&gt; id $6.&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=work.trans6;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8335i51A5B856A3D73379/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="output.JPG" title="output.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;55&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;56 FILENAME trans6'/folders/myfolders/transaction_date.txt';&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;57&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;58 data trans6;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;59 infile trans6;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;60 input @1 trans_date mmddyy10.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61 &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70859"&gt;@12&lt;/a&gt; id $6.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;62 ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;63 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The infile TRANS6 is:&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Filename=/folders/myfolders/transaction_date.txt,&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Owner Name=root,Group Name=vboxsf,&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Access Permission=-rwxrwx---,&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;Last Modified=16Apr2017:14:32:11,&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;File Size (bytes)=50&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: 3 records were read from the infile TRANS6.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The minimum record length was 12.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;The maximum record length was 17.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The data set WORK.TRANS6 has 2 observations and 2 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;64&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;65 proc print data=work.trans6;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;66 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: There were 2 observations read from the data set WORK.TRANS6.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.02 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.03 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;67&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;68&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;69 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81&lt;/DIV&gt;</description>
      <pubDate>Sun, 16 Apr 2017 18:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350377#M81430</guid>
      <dc:creator>soumyatejas</dc:creator>
      <dc:date>2017-04-16T18:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from file - issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350379#M81431</link>
      <description>&lt;P&gt;Add the truncover option to your infile statement. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;FILENAME trans6 '/folders/myfolders/transaction_date.txt';

data trans6;
  infile trans6 truncover;
  input @1 trans_date mmddyy10.
  @12 id $6.;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 19:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350379#M81431</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-16T19:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from file - issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350380#M81432</link>
      <description>Thank you, it works fine now.</description>
      <pubDate>Sun, 16 Apr 2017 19:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350380#M81432</guid>
      <dc:creator>soumyatejas</dc:creator>
      <dc:date>2017-04-16T19:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from file - issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350387#M81433</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; When you read a file like this, SAS is telling you in the log, what is wrong with these lines:&lt;/P&gt;
&lt;DIV class="sasNote"&gt;&lt;STRONG&gt;The minimum record length was 12.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;STRONG&gt;The maximum record length was 17.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;And if you look at the file in Notepad,&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8336i3E93CB930E721021/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="what_is_in_file.png" title="what_is_in_file.png" /&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;you can see that indeed, the middle data line is only 12 bytes long. But with formatted input, such as you have used, when SAS gets to the second line and does not find&amp;nbsp;the right number of bytes for ID (you told it $6), then you get the message:&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;STRONG&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;SPAN&gt;Because the INPUT statement went to the next line to "satisfy" the need to read $6, as you instructed.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;SPAN&gt;&amp;nbsp; There are other ways to read this data file. The easiest is to switch to LIST input, as shown below, but you can stick with formatted input if you use $varying to read ID. Other options, like PAD and/or MISSOVER can help you here. In total, there are 4 ways shown in my examples, There are probably more ways.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasNote"&gt;&lt;SPAN&gt;cynthia&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8337iDC6D255040B9D90D/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="simple_list_input_easiest.png" title="simple_list_input_easiest.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 19:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350387#M81433</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-04-16T19:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from file - issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350388#M81434</link>
      <description>Good catch, Art! I completely spaced out on TRUNCOVER.&lt;BR /&gt;cynthia</description>
      <pubDate>Sun, 16 Apr 2017 19:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-data-from-file-issue/m-p/350388#M81434</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-04-16T19:50:30Z</dc:date>
    </item>
  </channel>
</rss>

