<?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 fixed Data problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402077#M97601</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170069"&gt;@leibahay&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In your code you assign INFORMATS to your variables which is great for list input but you then in your input statement you're using column input (defining exactly the from and two column positions where you want to read your data from).&lt;/P&gt;
&lt;P&gt;It looks like your data is not exactly in the columns where you expect it to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use list input style instead. Below code shows you what you need to change.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testscore;
  infile datalines truncover
    dlm=' ';
  informat id $3.
    test1 2.
    test2 2. test3 2. test4 2. test5 2.;
  input
    id $
    test1 
    test2 
    test3 
    test4 
    test5 
  ;
  datalines;
001 18 53 53 48 73
002 61 81 . 98 1
003 31 65 35 92 35
004 84 42 82 . 19
005 97 33 14 44 9
006 52 40 . 85 93
007 5 . 29 68 37
008 37 42 24 56 32
009 14 54 15 70 39
010 8 32 49 . 17
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 07 Oct 2017 13:24:42 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-10-07T13:24:42Z</dc:date>
    <item>
      <title>Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401935#M97546</link>
      <description>&lt;P&gt;Hi, I just started to learn SAS and I was trying to read the following fixed data with'.' as missing value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 18 53 53 48 73&lt;BR /&gt;002 61 81 . 98 1&lt;BR /&gt;003 31 65 35 92 35&lt;BR /&gt;004 84 42 82 . 19&lt;BR /&gt;005 97 33 14 44 9&lt;BR /&gt;006 52 40 . 85 93&lt;BR /&gt;007 5 . 29 68 37&lt;BR /&gt;008 37 42 24 56 32&lt;BR /&gt;009 14 54 15 70 39&lt;BR /&gt;010 8 32 49 . 17&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, when i printed it out, row 7 and 10 are not read properly and I don't know what the problem is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.35.06 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15683iF008F3625C52D80B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.35.06 PM.png" alt="Screen Shot 2017-10-06 at 4.35.06 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 20:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401935#M97546</guid>
      <dc:creator>leibahay</dc:creator>
      <dc:date>2017-10-06T20:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401947#M97551</link>
      <description>&lt;P&gt;Post your code and log.&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/170069"&gt;@leibahay&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I just started to learn SAS and I was trying to read the following fixed data with'.' as missing value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;001 18 53 53 48 73&lt;BR /&gt;002 61 81 . 98 1&lt;BR /&gt;003 31 65 35 92 35&lt;BR /&gt;004 84 42 82 . 19&lt;BR /&gt;005 97 33 14 44 9&lt;BR /&gt;006 52 40 . 85 93&lt;BR /&gt;007 5 . 29 68 37&lt;BR /&gt;008 37 42 24 56 32&lt;BR /&gt;009 14 54 15 70 39&lt;BR /&gt;010 8 32 49 . 17&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;however, when i printed it out, row 7 and 10 are not read properly and I don't know what the problem is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.35.06 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15683iF008F3625C52D80B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.35.06 PM.png" alt="Screen Shot 2017-10-06 at 4.35.06 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 20:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401947#M97551</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-06T20:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401952#M97554</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.34.54 PM.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15685i32B21B14B443E7DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.34.54 PM.png" alt="Screen Shot 2017-10-06 at 4.34.54 PM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.57.26 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15686i14DE049041A19F7A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.57.26 PM.png" alt="Screen Shot 2017-10-06 at 4.57.26 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 20:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401952#M97554</guid>
      <dc:creator>leibahay</dc:creator>
      <dc:date>2017-10-06T20:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401958#M97559</link>
      <description>&lt;P&gt;post it as text.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170069"&gt;@leibahay&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.34.54 PM.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15685i32B21B14B443E7DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.34.54 PM.png" alt="Screen Shot 2017-10-06 at 4.34.54 PM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-06 at 4.57.26 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15686i14DE049041A19F7A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-06 at 4.57.26 PM.png" alt="Screen Shot 2017-10-06 at 4.57.26 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 21:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401958#M97559</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-06T21:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401961#M97561</link>
      <description>&lt;P&gt;Sorry, I am new here. So I don't know the format of the poste &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you for your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data testscore;&lt;BR /&gt;infile datalines truncover&lt;BR /&gt;dlm=' ';&lt;BR /&gt;informat id $3.&lt;BR /&gt;test1 2.&lt;BR /&gt;test2 2. test3 2. test4 2. test5 2.;&lt;BR /&gt;input&lt;BR /&gt;id $&lt;BR /&gt;test1 5-6&lt;BR /&gt;test2 8-9&lt;BR /&gt;test3 11-12&lt;BR /&gt;test4 13-15&lt;BR /&gt;test5 16-18&lt;BR /&gt;;&lt;BR /&gt;datalines;&lt;BR /&gt;001 18 53 53 48 73&lt;BR /&gt;002 61 81 . 98 1&lt;BR /&gt;003 31 65 35 92 35&lt;BR /&gt;004 84 42 82 . 19&lt;BR /&gt;005 97 33 14 44 9&lt;BR /&gt;006 52 40 . 85 93&lt;BR /&gt;007 5 . 29 68 37&lt;BR /&gt;008 37 42 24 56 32&lt;BR /&gt;009 14 54 15 70 39&lt;BR /&gt;010 8 32 49 . 17&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=testscore;&lt;BR /&gt;format id $3. ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 21:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401961#M97561</guid>
      <dc:creator>leibahay</dc:creator>
      <dc:date>2017-10-06T21:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401966#M97565</link>
      <description>&lt;P&gt;You need to use the insert code button otherwise it loses it's spacing, which is important when you're reading a fixed width file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate, your column indexes are off. Count out your layout again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 21:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401966#M97565</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-06T21:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401980#M97576</link>
      <description>&lt;P&gt;It is hard to tell since you posted the data into the text box instead of using the pop-ups for code or SAS code.&amp;nbsp; That can remove spaces and make other changes.&lt;/P&gt;
&lt;P&gt;But it looks to me like your data is NOT in fixed columns like your subject line said. But it does look like you have marked missing value with periods so simple list mode should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile 'myfile' truncover ;
  input id test1-test5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 22:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/401980#M97576</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-06T22:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402034#M97592</link>
      <description>&lt;P&gt;Hard to tell from photographs but it looks like you might have two issues.&lt;/P&gt;
&lt;P&gt;1) You don't seem to have used the right column numbers in your INPUT statement.&lt;/P&gt;
&lt;P&gt;2) It also looks like something has replaced some of your spaces with tabs. (NOTE:&amp;nbsp;If you are using SAS as your editor there are options to prevent it from inserting tabs into your programs. I am sure other editors also have those options).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be easy to fix the first problem, just count better. The second you can fix by using an INFILE statement with the EXPANDTABS option, although that really depends on whether the program that inserted the tabs is using the standard 8 character tabs that SAS will use for expanding the tabs.&amp;nbsp; (Note there is no need to use DLM=' ' on the INFILE statement since spaces are the default delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile datalines truncover expandtabs ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that it also looks like there is no need to read that data as fixed length since there appear to be one or more spaces between every value. missing values are clearly marked with periods and there are no spaces embedded in the middle of the any of the values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length id $3 ;
input id test1-test5;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Oct 2017 03:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402034#M97592</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-07T03:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402077#M97601</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170069"&gt;@leibahay&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;In your code you assign INFORMATS to your variables which is great for list input but you then in your input statement you're using column input (defining exactly the from and two column positions where you want to read your data from).&lt;/P&gt;
&lt;P&gt;It looks like your data is not exactly in the columns where you expect it to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use list input style instead. Below code shows you what you need to change.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testscore;
  infile datalines truncover
    dlm=' ';
  informat id $3.
    test1 2.
    test2 2. test3 2. test4 2. test5 2.;
  input
    id $
    test1 
    test2 
    test3 
    test4 
    test5 
  ;
  datalines;
001 18 53 53 48 73
002 61 81 . 98 1
003 31 65 35 92 35
004 84 42 82 . 19
005 97 33 14 44 9
006 52 40 . 85 93
007 5 . 29 68 37
008 37 42 24 56 32
009 14 54 15 70 39
010 8 32 49 . 17
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 Oct 2017 13:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402077#M97601</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-07T13:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402080#M97602</link>
      <description>I have seen many files containing data in fixed width format. None of these had blanks as field separator or dots. So follow Toms suggestion to solve the issue.</description>
      <pubDate>Sat, 07 Oct 2017 13:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402080#M97602</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-07T13:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reading fixed Data problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402127#M97624</link>
      <description>&lt;P&gt;This seems working. What is the function of expandtabs exactly? Haven't seen this yet &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for you time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2017 23:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-fixed-Data-problem/m-p/402127#M97624</guid>
      <dc:creator>leibahay</dc:creator>
      <dc:date>2017-10-07T23:55:15Z</dc:date>
    </item>
  </channel>
</rss>

