<?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 query in SAS help in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98990#M27838</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try adding a group by on the accounts&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Feb 2013 20:28:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-02-05T20:28:13Z</dc:date>
    <item>
      <title>SQL query in SAS help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98989#M27837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table like the following (named test) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; WIDTH: 100%; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Account&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Type&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;11111&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;CO&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;22222&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;PH&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;9999&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;33333&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;TIP&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12034&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;33333&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;CO&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1345156&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;33333&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;PH&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12314&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;44444&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;CO&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;23414&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And another table named cl_prior_accounts from which I want to pull all account and lookup if I have data in my table test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I run the following codeL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt; CREATE TABLE cl_prior.cl_prior_ent_final AS SELECT &lt;/P&gt;&lt;P&gt; cl_prior_accounts.Accounts,&lt;/P&gt;&lt;P&gt;&amp;nbsp; (case when&amp;nbsp; test.type = "CO" then test.amount end) as SUM_OF_CO_ACC,&lt;/P&gt;&lt;P&gt;&amp;nbsp; (case when&amp;nbsp; test.type = "PH" then&amp;nbsp; test.amount end) as SUM_OF_PH_ACC,&lt;/P&gt;&lt;P&gt;&amp;nbsp; (case when&amp;nbsp; test.type = "TIP" then test.amount end) as SUM_OF_TIP_ACC&lt;/P&gt;&lt;P&gt;&amp;nbsp; FROM mylib.cl_prior_accounts AS cl_prior_accounts&lt;/P&gt;&lt;P&gt; LEFT JOIN mylib.test as test ON (cl_prior_accounts.accounts = test.accounts)&lt;/P&gt;&lt;P&gt;;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For account number 33333 I get three row of data; one for each type of account. I would like to have all that information on one line for account 33333. How do I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still want to use left join in order to have all my accounts from cl_prior_accounts table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 20:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98989#M27837</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-05T20:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query in SAS help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98990#M27838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try adding a group by on the accounts&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 20:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98990#M27838</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-02-05T20:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query in SAS help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98991#M27839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Group by did the work. You just have to use sum( ) on the case statement in order for them to be grouped.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Feb 2013 21:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-in-SAS-help/m-p/98991#M27839</guid>
      <dc:creator>nicnad</dc:creator>
      <dc:date>2013-02-05T21:44:07Z</dc:date>
    </item>
  </channel>
</rss>

