<?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: Program output errors - Invalid data for total in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647224#M22131</link>
    <description>Thanks! That fixed the problem.</description>
    <pubDate>Tue, 12 May 2020 20:22:17 GMT</pubDate>
    <dc:creator>ThetaIchnaea</dc:creator>
    <dc:date>2020-05-12T20:22:17Z</dc:date>
    <item>
      <title>Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647136#M22120</link>
      <description>&lt;P&gt;I'm doing an introductory course in SAS, and when I copy the code in one of the videos, I get different results. I have no idea what is going wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sales;
input name$ sales1-sales4 total;
total = sales1 + sales2 + sales3 + sales4;

datalines;
Greg 10 2 40 0
John 15 5 10 100
Lisa 50 10 15 50
Mark 20 0 5 20
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The output should give the four lines with six colums: name, four sales values, and the total per person. When I run this code in SAS Studio (University Edition, latest version), I get only result for Greg and Lisa.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for total in line 79 1-4.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 John 15 5 10 100&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;name=Greg sales1=10 sales2=2 sales3=40 sales4=0 total=52 _ERROR_=1 _N_=1&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Invalid data for total in line 81 1-4.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81 Mark 20 0 5 20&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;name=Lisa sales1=50 sales2=10 sales3=15 sales4=50 total=125 _ERROR_=1 _N_=2&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;I don't see what is wrong with the data and what causes this error. I've created a text file with the four datalines, and used that with an INFILE command, but that didn't make any difference. Can you explain or help me out?&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 15:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647136#M22120</guid>
      <dc:creator>ThetaIchnaea</dc:creator>
      <dc:date>2020-05-12T15:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647137#M22121</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327982"&gt;@ThetaIchnaea&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually, the TOTAL variable is a computed one.&lt;/P&gt;
&lt;P&gt;It is not present in the input data.&lt;/P&gt;
&lt;P&gt;So you need to remove it from the input statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sales;
input name$ sales1-sales4 ;
total = sales1 + sales2 + sales3 + sales4;

datalines;
Greg 10 2 40 0
John 15 5 10 100
Lisa 50 10 15 50
Mark 20 0 5 20
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 15:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647137#M22121</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-12T15:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647143#M22124</link>
      <description>&lt;DIV class="sasNote"&gt;NOTE: Invalid data for &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;total&lt;/STRONG&gt;&lt;/FONT&gt; in line &lt;STRONG&gt;&lt;FONT color="#FF9900"&gt;79&lt;/FONT&gt; &lt;FONT color="#339966"&gt;1-4&lt;/FONT&gt;.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT color="#FF9900"&gt;&lt;STRONG&gt;79&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#339966"&gt;&lt;STRONG&gt;John&lt;/STRONG&gt;&lt;/FONT&gt; 15 5 10 100&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;The error tells you SAS is trying to read in data for a variable called total and when to the next line (flowover is the default in INFILE statement) to try and find that value. Since it's a calculated column it doesn't need to be in the INPUT statement. I highlighted the data in the NOTE that illustrates how you can determine what's happening.&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 12 May 2020 16:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647143#M22124</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-12T16:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647224#M22131</link>
      <description>Thanks! That fixed the problem.</description>
      <pubDate>Tue, 12 May 2020 20:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647224#M22131</guid>
      <dc:creator>ThetaIchnaea</dc:creator>
      <dc:date>2020-05-12T20:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647226#M22132</link>
      <description>So it means that with INFILE it reads Greg, then sales 1-4, and then tries to read total. There is no total on the first line, so it goes to the second line, where it finds John, which results in an error because it's character data and not a value. That's why it doesn't display the John line? Is that how this works?&lt;BR /&gt;&lt;BR /&gt;Knowing that TOTAL should be removed from INPUT is useful, but knowing how to read the log is even better.</description>
      <pubDate>Tue, 12 May 2020 20:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647226#M22132</guid>
      <dc:creator>ThetaIchnaea</dc:creator>
      <dc:date>2020-05-12T20:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Program output errors - Invalid data for total</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647252#M22133</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327982"&gt;@ThetaIchnaea&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;So it means that with INFILE it reads Greg, then sales 1-4, and then tries to read total. There is no total on the first line, so it goes to the second line, where it finds John, which results in an error because it's character data and not a value. That's why it doesn't display the John line? Is that how this works?&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, that's correct. Another possible correction could be to add the TRUNCOVER option to the INFILE statement which would tell SAS not to go to a new line when it doesn't find the total value.&amp;nbsp; Then it should stay empty and be filled in with the calculation in the next step. You will likely still get Notes in the log with this method though but it's worth noting the option. IMO the default for INFILE should be changed to TRUNCOVER due to how we store files today but SAS will likely not change this due to backwards compatibility issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile cards truncover;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 May 2020 21:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Program-output-errors-Invalid-data-for-total/m-p/647252#M22133</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-12T21:41:38Z</dc:date>
    </item>
  </channel>
</rss>

