<?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: Instead of Partition By in SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Instead-of-Partition-By-in-SQL/m-p/657525#M197035</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254213"&gt;@cmemtsa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not using a PROC MEANS instead?&lt;/P&gt;
&lt;P&gt;You can then filter on the _type_ variable to get the desired results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=t noprint;
	class p L Cd;
	var Exp MV;
	output out=want sum=/autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 13:50:35 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-06-11T13:50:35Z</dc:date>
    <item>
      <title>Instead of Partition By in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Instead-of-Partition-By-in-SQL/m-p/657355#M197030</link>
      <description>&lt;P&gt;Hi to all!&lt;/P&gt;
&lt;P&gt;I have to find sums in one table but based on different Grouping be each time (relevant Partition by in SQL). How can I do it?&lt;/P&gt;
&lt;P&gt;In this code I want to find Sum(Exp) group by P, sum(Exp) group by P, L and sum(MV) group by P, Cd). How many inner joins I need?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select * 

from 
(((select P, L, Exp, MV, sum(Exp) as TotalExpPL,  from t group by P, L) t2
inner join 
(select P, sum(Exp) as TotalExpP from t group by P) t1
on t1.P=t2.P)
((select  P, Cd, sum(MV) as TotalMVPCD from t group by P, Cd) t3
inner join on t1.P=t3.P))
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jun 2020 09:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Instead-of-Partition-By-in-SQL/m-p/657355#M197030</guid>
      <dc:creator>cmemtsa</dc:creator>
      <dc:date>2020-06-11T09:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Instead of Partition By in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Instead-of-Partition-By-in-SQL/m-p/657525#M197035</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254213"&gt;@cmemtsa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not using a PROC MEANS instead?&lt;/P&gt;
&lt;P&gt;You can then filter on the _type_ variable to get the desired results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=t noprint;
	class p L Cd;
	var Exp MV;
	output out=want sum=/autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Instead-of-Partition-By-in-SQL/m-p/657525#M197035</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-11T13:50:35Z</dc:date>
    </item>
  </channel>
</rss>

