<?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: How To use Where instead of Group by ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592141#M169743</link>
    <description>&lt;P&gt;Generally, GROUP BY and WHERE are not interchangeable, they do very different things. So its not clear why you want to exchange one for the other.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Next, the construct&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;(WHERE=(DIVISION_ID=3))&lt;/FONT&gt;&amp;nbsp;is a data set option which can only be applied to data sets, is that where you tried to use it? It won't work elsewhere in SQL code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you're not getting something that works, show us the code you tried — better yet, show us the LOG, including all the code and any error messages.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2019 12:06:06 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-09-27T12:06:06Z</dc:date>
    <item>
      <title>How To use Where instead of Group by ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592121#M169738</link>
      <description>&lt;P&gt;Hello Everyone , I wrote a query , that gives me this Output :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 192pt;" border="0" width="256" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" style="height: 14.4pt; width: 48pt;"&gt;ID_User&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Division_ID&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Tot_Item&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Max_Item&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;1988&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;50&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;1541&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;121&lt;/TD&gt;
&lt;TD align="right"&gt;32&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;4451&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;333&lt;/TD&gt;
&lt;TD align="right"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;(This is Just a sample obviously the Output Table contains 300000 rows approximatly)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And This is my Query :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create Table Output as 
select ID_User, Division_ID, sum(conta) as Tot_Items, max(Counts) as Max_Item
from (select c.ID_User , c.Div_ID as Division_ID, ro.code as Mat, count(*) as Counts
      from Ods.R_Ordini o
	  inner join DMC.Cust_Dupl c
	   on User_ID = ID_User
	  inner join ods.R_Nlines ro
	   on ro.Orders_Id = o.Id_Orders AND RO.SERVICE = 0
	  inner join ods.R_Mat m
	   on ro.Mat_Id = Id_Mat and flag = 0
	  group by 
	      ID_User,
		  C.Division_ID,
		  Ro.Code
	      Having Counts &amp;gt; 1
)
group by
      Id_User,
      Division_ID
Order by 
      Tot_Item DESC
 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So , What i want is to re-write this Query , but instead of the Group by i want to use the Where Condition , (WHERE=(DIVISION_ID=3)) this is the condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried several attempts , with some i got errors , and with others i did got an output , but the output was not like the original one.&lt;/P&gt;
&lt;P&gt;any help would be much appreciated , thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 10:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592121#M169738</guid>
      <dc:creator>Midi</dc:creator>
      <dc:date>2019-09-27T10:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: How To use Where instead of Group by ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592133#M169741</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/282666"&gt;@Midi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you do you want to accomplish in&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"but instead of the Group by i want to use the Where Condition , (WHERE=(DIVISION_ID=3)) this is the condition."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to understand&lt;STRONG&gt;&lt;EM&gt; instead of&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do you mean you want to add&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE=(DIVISION_ID=3)) after the FROM clause?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you clarify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 11:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592133#M169741</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-27T11:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How To use Where instead of Group by ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592141#M169743</link>
      <description>&lt;P&gt;Generally, GROUP BY and WHERE are not interchangeable, they do very different things. So its not clear why you want to exchange one for the other.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Next, the construct&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;(WHERE=(DIVISION_ID=3))&lt;/FONT&gt;&amp;nbsp;is a data set option which can only be applied to data sets, is that where you tried to use it? It won't work elsewhere in SQL code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you're not getting something that works, show us the code you tried — better yet, show us the LOG, including all the code and any error messages.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 12:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-To-use-Where-instead-of-Group-by/m-p/592141#M169743</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-27T12:06:06Z</dc:date>
    </item>
  </channel>
</rss>

