<?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: SQL command in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27942#M6448</link>
    <description>Hi Photo,&lt;BR /&gt;
            For accomplishing your task, the code posted by Mr.Olivier is enough but for creating a data set, the following code is helpful &lt;BR /&gt;
&lt;BR /&gt;
data total;&lt;BR /&gt;
set productcode;&lt;BR /&gt;
by productcode;&lt;BR /&gt;
if first.productcode then do;&lt;BR /&gt;
total_cost+cost;&lt;BR /&gt;
end;&lt;BR /&gt;
if last.productcode;&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 01 Jul 2008 10:04:53 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-07-01T10:04:53Z</dc:date>
    <item>
      <title>SQL command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27940#M6446</link>
      <description>I have data&lt;BR /&gt;
   productcode and cost of each product, i group it by productcode i have total cost of each productcode but i don't have the amount of total cost of every product at the last line, could you help me how to do ?&lt;BR /&gt;
productcode    cost&lt;BR /&gt;
A                    100&lt;BR /&gt;
A                     20&lt;BR /&gt;
B                     200&lt;BR /&gt;
B                      50&lt;BR /&gt;
C                     220&lt;BR /&gt;
....&lt;BR /&gt;
my command&lt;BR /&gt;
select productcode,sum(cost)&lt;BR /&gt;
from data&lt;BR /&gt;
group by productcode &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I need the last line 490 (total of every product)&lt;BR /&gt;
many thanks.</description>
      <pubDate>Thu, 26 Jun 2008 11:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27940#M6446</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-26T11:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27941#M6447</link>
      <description>This is not really the SQL way of thinking to add grand total lines in a report or a data set. What you can do is same the result of your query in a SAS data set (CREATE TABLE ... AS SELECT etc.) and then display the dataset with a PRINT procedure, using the SUM statement to add the final row :&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC PRINT DATA = queryResult LABEL NOOBS ;&lt;BR /&gt;
  SUM cost ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Tue, 01 Jul 2008 09:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27941#M6447</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-07-01T09:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: SQL command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27942#M6448</link>
      <description>Hi Photo,&lt;BR /&gt;
            For accomplishing your task, the code posted by Mr.Olivier is enough but for creating a data set, the following code is helpful &lt;BR /&gt;
&lt;BR /&gt;
data total;&lt;BR /&gt;
set productcode;&lt;BR /&gt;
by productcode;&lt;BR /&gt;
if first.productcode then do;&lt;BR /&gt;
total_cost+cost;&lt;BR /&gt;
end;&lt;BR /&gt;
if last.productcode;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 01 Jul 2008 10:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27942#M6448</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-01T10:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: SQL command</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27943#M6449</link>
      <description>As oliver said proc is the best way.. U may use an ods to convert is back to data set..</description>
      <pubDate>Wed, 02 Jul 2008 19:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-command/m-p/27943#M6449</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-02T19:14:16Z</dc:date>
    </item>
  </channel>
</rss>

