<?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 multiple variables from different lines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717221#M221776</link>
    <description>&lt;P&gt;It's not obvious what is wrong looking at your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have 4 lines per block, it seems right to use n=4, not n=3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding TRUNCOVER to the INFILE statement might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 21:26:43 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-02-05T21:26:43Z</dc:date>
    <item>
      <title>Reading multiple variables from different lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717217#M221775</link>
      <description>&lt;P&gt;So I have Data that's stacked like this:&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&amp;nbsp;&lt;/P&gt;&lt;P&gt;890,,,900&lt;/P&gt;&lt;P&gt;red&lt;/P&gt;&lt;P&gt;Contractor&lt;/P&gt;&lt;P&gt;Marie&lt;/P&gt;&lt;P&gt;900,,,888&amp;nbsp;&lt;/P&gt;&lt;P&gt;purple&lt;/P&gt;&lt;P&gt;Manager&lt;/P&gt;&lt;P&gt;Giselle&lt;/P&gt;&lt;P&gt;100,,,000&lt;/P&gt;&lt;P&gt;orange&lt;/P&gt;&lt;P&gt;President&amp;nbsp;&lt;/P&gt;&lt;P&gt;Coming in as 4 different variables (name,id1,color, title) and I need to read them in with, I'm assuming, some combination of line holders and pointer controls.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I have&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data emp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;infile employee firstobs = 2 /* Because there is some random text in the file at the beginning*/ n = 3;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; input #1 name 1-20 #2 id $10. #3 color $50. #4 title $50.;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; right now, whenever I run this, it reads in the first line correctly and then skips a line and starts reading in everything which is causing everything else to mess up.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the output looks like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Color&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Title&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 890,,,900&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Red&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Contractor&amp;nbsp;&lt;/P&gt;&lt;P&gt;900,,,888&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;purple&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Giselle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why this is happening? I feel like i've tried an endless combination of line pointer controls and hold specifiers but haven't gotten anywhere&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 21:17:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717217#M221775</guid>
      <dc:creator>nithya_r99</dc:creator>
      <dc:date>2021-02-05T21:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple variables from different lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717221#M221776</link>
      <description>&lt;P&gt;It's not obvious what is wrong looking at your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you have 4 lines per block, it seems right to use n=4, not n=3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding TRUNCOVER to the INFILE statement might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 21:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717221#M221776</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-02-05T21:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple variables from different lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717228#M221779</link>
      <description>&lt;P&gt;The problem is the way you provide the Informats on the input statement.&lt;/P&gt;
&lt;P&gt;When you use&lt;/P&gt;
&lt;P&gt;Input id $10. ; SAS reads 10 characters. If the value runs out then in continues on the next line. With list type data you may need the : input modifier to accept shorter values.&lt;/P&gt;
&lt;P&gt;Similar, when you have Input name 1-20 your are reading a NUMERIC value.&lt;/P&gt;
&lt;P&gt;You would want Input name $ 1-20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please. For text data to read paste it into a text box opened on the forum with the &amp;lt;/&amp;gt; icon. The main message windows will reformat pasted text and sometimes inserts characters that you don't see. So we can't actually run against your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is that simple an &lt;STRONG&gt;always&lt;/STRONG&gt; is 4 lines you may be able to use the input statement / instruction to read from the next line as below.&lt;/P&gt;
&lt;PRE&gt;data emp; 
    informat name $20. id $10. color $50. title $50.; 
    input name / id  / color  / title; 
datalines;
John 
890,,,900
red
Contractor
Marie
900,,,888 
purple
Manager
Giselle
100,,,000
orange
President 
;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;data emp; 
    input name $ 1-20 / id :$10. / color :$50. / title :$50.; 
datalines;
John 
890,,,900
red
Contractor
Marie
900,,,888 
purple
Manager
Giselle
100,,,000
orange
President 
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 21:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-multiple-variables-from-different-lines/m-p/717228#M221779</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-05T21:53:45Z</dc:date>
    </item>
  </channel>
</rss>

