<?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: Error statement show in proc sql 'sum' statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366693#M275216</link>
    <description>&lt;P&gt;The N1-N3 showes all the numbers '1'.&amp;nbsp; It doesn't show the total of Num1=5, Num2=3, Num3=7.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2017 17:22:11 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2017-06-13T17:22:11Z</dc:date>
    <item>
      <title>Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366626#M275211</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote some codes below.&amp;nbsp; The data are shown in the attachment.&amp;nbsp; Could someone help me to fix it?&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;contents&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=contents &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=have (keep=NAME);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; total &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;sum(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'Gm_go'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; N1, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;sum(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'gm_hhrt'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; N2,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;sun(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'gm_certificate'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; N3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;However, error messages are shown in the log.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;55 proc sql;&lt;/P&gt;&lt;P&gt;56 create table total as&lt;/P&gt;&lt;P&gt;57 select&lt;/P&gt;&lt;P&gt;58 sum(where 'Gm_go' in name) as N1,&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;200&lt;/P&gt;&lt;P&gt;59 sum(where 'gm_hhrt' in name) as N2,&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---------&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;60 sun(where 'gm_certificate' in name) as N3&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ----------------&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, ), *, **, +, ',', -, '.', /,&lt;/P&gt;&lt;P&gt;&amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,&lt;/P&gt;&lt;P&gt;LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;61 from have;&lt;/P&gt;&lt;P&gt;62 quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366626#M275211</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-13T15:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366628#M275212</link>
      <description>&lt;P&gt;You can't put WHERE inside a SUM function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366628#M275212</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T15:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366673#M275213</link>
      <description>&lt;P&gt;And SUM needs a variable to sum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might look into proc means or summary:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc summary data=have nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class name;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var &amp;lt;what ever variable you want the sum of goes here&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=havesum sum=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;creates a sum of the variable for each level of the NAME variable.&lt;/P&gt;
&lt;P&gt;If you really must have the data in wide form then Transpose the data.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 16:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366673#M275213</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-13T16:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366691#M275214</link>
      <description>&lt;P&gt;I generated the codes below based on your suggesion.&amp;nbsp; However, I found the Num1-Num3 is not the total counts of N1-N3.&amp;nbsp; How to fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc summary data=have nway;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; class name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var N1-N3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output out=havesum sum=Num1-Num3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 16:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366691#M275214</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-13T16:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366692#M275215</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;However, I found the Num1-Num3 is not the total counts of N1-N3.&amp;nbsp; How to fix it?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What that does mean?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 17:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366692#M275215</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T17:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366693#M275216</link>
      <description>&lt;P&gt;The N1-N3 showes all the numbers '1'.&amp;nbsp; It doesn't show the total of Num1=5, Num2=3, Num3=7.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 17:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366693#M275216</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-13T17:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366698#M275217</link>
      <description>&lt;P&gt;Did your proc run? I would expect it to error out actually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want counts, use PROC FREQ, especially if the numbers are all 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Summarizing data is a basic task. Read one of the papers that introduce you to PROC MEANs.&lt;/P&gt;
&lt;P&gt;Taking 15 minutes to read a paper will result in saving at least 20 minutes for each of your questions, times 2-3 questions a day = 1 hour a day at least.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://lexjansen.com/search/searchresults.php?q=Proc%20means%20intro" target="_blank"&gt;http://lexjansen.com/search/searchresults.php?q=Proc%20means%20intro&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc tabulate data=have;
Class name;&lt;BR /&gt;var n1 n2 n3;
Table (name all), (n1 n2 n3)*sum;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that you're also summarizing by NAME variable. Make sure you have multiple records per name, otherwise this won't make sense&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc means data=have nway;
Class name;
Var n1 n2 n3;
Output out=want sum = /autoname;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 17:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366698#M275217</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T17:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366748#M275218</link>
      <description>&lt;P&gt;What does your input data look like?&lt;/P&gt;
&lt;P&gt;We have no idea what your HAVE data set looks like at this time.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 19:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366748#M275218</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-13T19:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error statement show in proc sql 'sum' statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366774#M275219</link>
      <description>&lt;P&gt;Thanks for all of your kind help.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 20:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-statement-show-in-proc-sql-sum-statement/m-p/366774#M275219</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-13T20:52:30Z</dc:date>
    </item>
  </channel>
</rss>

