<?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 code in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122561#M33656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i mean i have "table" in my own query too but i was wondering if it s&amp;nbsp; necessary &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Jan 2013 04:05:17 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2013-01-11T04:05:17Z</dc:date>
    <item>
      <title>SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122558#M33653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;i have&amp;nbsp; a table A with the following fields &lt;STRONG&gt;date,x,y&lt;/STRONG&gt; that i want to group&amp;nbsp; by date and the sum of x and y&lt;/P&gt;&lt;P&gt;table A:&lt;/P&gt;&lt;P&gt;date x y&lt;/P&gt;&lt;P&gt;---------------&lt;/P&gt;&lt;P&gt;12-2-2012&amp;nbsp;&amp;nbsp; 4&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;12-2-2012&amp;nbsp; 6 7&lt;/P&gt;&lt;P&gt;12-5-2012&amp;nbsp;&amp;nbsp; 3 4&lt;/P&gt;&lt;P&gt;12-5-2012&amp;nbsp; 4 7&lt;/P&gt;&lt;P&gt;12-3-2012 2 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;table being grouped:&lt;/P&gt;&lt;P&gt;12-2-2012 10 12&lt;/P&gt;&lt;P&gt;12-5-2012 7 11&lt;/P&gt;&lt;P&gt;12-3-2012 2 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so when i run the query :&lt;STRONG&gt;select date,sum(x),sum(y) from table A group by date&lt;/STRONG&gt; i get the right results.&lt;/P&gt;&lt;P&gt;But when i try to save the results into a new table &lt;BR /&gt;(B) i get syntax errors (Incorrect syntax near the keyword 'as'.)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table B as (select date,sum(x),sum(y) from table A group by date);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i am running this on SQL Microsoft Studio 2008&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i am doing wrong here,anyone please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 03:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122558#M33653</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-11T03:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122559#M33654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table B as &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select date, sum(x) as xx,sum(y)&amp;nbsp; as yy&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from table A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&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; group by date;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 03:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122559#M33654</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-01-11T03:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122560#M33655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the quick response Linlin but i did run the same code w/o the brackets after "as" and before ; and i still get the error.Is "table" from&amp;nbsp;&amp;nbsp; "&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from table A" &lt;/STRONG&gt;really necessary ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 04:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122560#M33655</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-11T04:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122561#M33656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i mean i have "table" in my own query too but i was wondering if it s&amp;nbsp; necessary &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 04:05:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122561#M33656</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-11T04:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122562#M33657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;never mind the last question.I must have ran the first query without the "table" from "&lt;STRONG style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from table A" &lt;/STRONG&gt;otherwise it wont run but i still cannot run the second query&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 04:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122562#M33657</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-11T04:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122563#M33658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not 100% sure here, but I never use SAS SQL code on other SQL platforms.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be more precise, in SAS SQL you can create tables "on the fly" by using the "create table foo as ..." syntax but I think this is only a convenient SAS structure which will not translate over to other SQL platforms like microsoft visual studio (although it may for some, I don't know).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I thought this was a SAS forum, I will propose the following solution because the syntax below is also allowed in SAS SQL although sometimes unnecessary:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIrst create a blank shell for your table using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;create table B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date as date,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xx as float,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yy as float&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt; ;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background-color: #ffffff; text-decoration: underline; font-family: Arial;"&gt;Notice that there is no "as" after the create statement!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background-color: #ffffff; font-family: Arial;"&gt;Then insert into that table the values you want:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background-color: #ffffff; font-family: Arial;"&gt;&lt;STRONG&gt;insert into B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select date, sum(x) as xx,sum(y)&amp;nbsp; as yy&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from table A&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by date ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should note that some things may change depending on the syntax of SQL in microsoft visual studio... For instance the the round parenthases, (),&amp;nbsp; may be curly brackets, {}.And the declaration of "date as date" may require a different data type. I haven't used SQL in visual studio so I can't give you any exact code, but I think this will get you on your way...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: never aragafi&#xD;
Notice that there is no "as" after the create statement!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 14:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122563#M33658</guid>
      <dc:creator>never</dc:creator>
      <dc:date>2013-01-11T14:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122564#M33659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did I understand you to say you're not using SAS proc sql? "create table whatever as. . ." is SAS syntax, but is not&amp;nbsp; ANSI standard SQL. To create a&amp;nbsp; new table with a select statement in most SQL dialects, you use "select into", e.g.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select &amp;lt;your columns&amp;gt; into B&lt;/P&gt;&lt;P&gt;from A&lt;/P&gt;&lt;P&gt;group by date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which will create a new table b in the default database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Karl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 14:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122564#M33659</guid>
      <dc:creator>KarlK</dc:creator>
      <dc:date>2013-01-11T14:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122565#M33660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ANSI standard does allow the syntax of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table new_table_name as&lt;/P&gt;&lt;P&gt;select column_spec1,....,,&lt;/P&gt;&lt;P&gt;&amp;nbsp; from table_name&lt;/P&gt;&lt;P&gt; group by group_by_column_spec&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;The issue with your query (as you suspected) is the word 'table' in the from clause 'from table a'.&amp;nbsp; That clause should simply be 'from a'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 15:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122565#M33660</guid>
      <dc:creator>LarryWorley</dc:creator>
      <dc:date>2013-01-11T15:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122566#M33661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What LinLin has written is correct (and everyone else).&lt;/P&gt;&lt;P&gt;If you want to create a table from SQL you need to tell SAs to save &lt;STRONG&gt;sum(x)&lt;/STRONG&gt; &lt;STRONG&gt;as sum_X&lt;/STRONG&gt; and &lt;STRONG&gt;sum(y) as sum_Y&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am just making sure you noticed 'extra' &lt;STRONG&gt;AS&lt;/STRONG&gt;es.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best of luck.&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 16:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122566#M33661</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-01-11T16:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122567#M33662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, you're right, Larry. The OP mentioned MS Visual Studio, which I assumed sits on top of SQL Server, so I cranked up my SQL SRV 2012 and "create table as. . ." throws an error. You have to use "select . . . into . . .". That apparently is a MS quirk which I mistakenly took to be ANSI--always risky with MS products.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for schooling me.&lt;/P&gt;&lt;P&gt;Karl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 19:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122567#M33662</guid>
      <dc:creator>KarlK</dc:creator>
      <dc:date>2013-01-11T19:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122568#M33663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;actually Karl,i was running this queries on sql developer /oracle and the "create table as ..." worked&amp;nbsp; perfectly for me.Probably the issue was with sum(x),sum(y.I was forgetting the sum(x) as... or sum (y) as.. So thanks guys,thank you all&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jan 2013 17:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122568#M33663</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-12T17:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122569#M33664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i want to add another question to this &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;if let's say i need to calculate the total sum of&amp;nbsp; sum(x) and sum (y) of the table below can i achieve it with the same query or do i need to run another one?&lt;/P&gt;&lt;P&gt;12-2-2012 10 12&lt;/P&gt;&lt;P&gt;12-5-2012 7 11&lt;/P&gt;&lt;P&gt;12-3-2012 2 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; total:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 19 25&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jan 2013 22:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122569#M33664</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-13T22:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122570#M33665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Easy to do in SAS. Just use proc print; var date x y; sum x y; run;&lt;/P&gt;&lt;P&gt;In SQL it is harder because you need to create a table instead of a report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(select date,x,y from have)&lt;/P&gt;&lt;P&gt;union &lt;/P&gt;&lt;P&gt;(select . as date,sum(x) as x, sum(y) as y from have group by date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the date and the label "TOTAL" to appear in the same variable it would need to be character.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 00:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122570#M33665</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-14T00:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122571#M33666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 03:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-code/m-p/122571#M33666</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-01-14T03:33:58Z</dc:date>
    </item>
  </channel>
</rss>

