<?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: Help please in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295465#M61740</link>
    <description>&lt;P&gt;After the first input statement, that stays in the same input line because of the trailing @, the column pointer stays &lt;U&gt;where it was&lt;/U&gt; after reading &lt;FONT face="courier new,courier"&gt;source&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Therefore, the column pointer must be set to the beginning of the line before attempting to read&lt;FONT face="courier new,courier"&gt; id&lt;/FONT&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2016 11:23:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-08-31T11:23:45Z</dc:date>
    <item>
      <title>Explanation for code - reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295464#M61739</link>
      <description>&lt;P&gt;&lt;SPAN&gt;for given data:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;11 john  1 77
11 88    2 james
22 bobby 1 55
22 89    2 opey&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4779iCBAB2D20CE9B76A0/image-size/original?v=v2&amp;amp;px=-1" alt="question.JPG" title="question.JPG" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also , i coded as follows, though program works perfect, but I want to know why&amp;nbsp;((then input @1 id @4 score @12 name $5. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70859"&gt;@12﻿&lt;/a&gt; name $5. @10 source 1.;)) requires direct pointing , even id variable requires it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm"log;clear;output;clear";

DATA result2;
input @10 source 1.@; *recording in input buffer source ;

if source = 1 then input @1 id @4 name $5. @12 score @12 score @10 source 1. ;
if source = 2 then input @1 id @4 score @12 name $5. @12 name $5. @10 source 1.;

datalines;
11 john  1 77
11 88    2 james
22 bobby 1 55
22 89    2 opey
;

RUN;

PROC PRINT data = result2 noobs;
var source id name score;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;[Edit by Kurt Bremser] Moved program text to code window, corrected datalines so they match the input statement column pointers&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12908iE074EA89D2F6180A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="question.JPG" title="question.JPG" /&gt;</description>
      <pubDate>Wed, 31 Aug 2016 11:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295464#M61739</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-31T11:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help please</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295465#M61740</link>
      <description>&lt;P&gt;After the first input statement, that stays in the same input line because of the trailing @, the column pointer stays &lt;U&gt;where it was&lt;/U&gt; after reading &lt;FONT face="courier new,courier"&gt;source&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Therefore, the column pointer must be set to the beginning of the line before attempting to read&lt;FONT face="courier new,courier"&gt; id&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 11:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295465#M61740</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-31T11:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Explanation for code - reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295467#M61741</link>
      <description>&lt;P&gt;PS you could simplify your code like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data result2;
input @10 source 1. @1 @; *recording in input buffer source ;
if source = 1 then input id @4 name $5. @12 score @12 score @10 source 1. ;
if source = 2 then input id @4 score @12 name $5. @12 name $5. @10 source 1.;
datalines;
11 john  1 77
11 88    2 james
22 bobby 1 55
22 89    2 opey
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2016 11:28:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295467#M61741</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-31T11:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Explanation for code - reading a text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295468#M61742</link>
      <description>&lt;P&gt;You input file a fixed width file so each variable starts at a specified column. Consider how it handles a name such as John Paul.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has two layouts sending on source column. I think your input statements for source is incorrect as you read name/score twice.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sample data posted doesn't reflect this because of formatting in forum most likely.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 11:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-for-code-reading-a-text-file/m-p/295468#M61742</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-31T11:29:41Z</dc:date>
    </item>
  </channel>
</rss>

