<?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 Calculating IQR, Q1 and Q3 with a group by in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365133#M23928</link>
    <description>&lt;P&gt;&amp;nbsp;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to calculate Q1, Q3 and IQR to identify outliers from a dataset. The problem is that I need Q1, Q3 and IQR for each client and each product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I calculate the Median, I have no problems, but with the other measures it doesn't work the way I expect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table "Output" as
           select *, median(quantity) as median, PCTL(25,quantity) as Q1, PCTL(75,quantity) as Q3, IQR(quantity) as IQR
                    from work.documentX
group by Client, Product;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I uploaded an example with an excel sheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for you help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Federico.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2017 18:31:46 GMT</pubDate>
    <dc:creator>jfcubells</dc:creator>
    <dc:date>2017-06-07T18:31:46Z</dc:date>
    <item>
      <title>Calculating IQR, Q1 and Q3 with a group by</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365133#M23928</link>
      <description>&lt;P&gt;&amp;nbsp;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to calculate Q1, Q3 and IQR to identify outliers from a dataset. The problem is that I need Q1, Q3 and IQR for each client and each product.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I calculate the Median, I have no problems, but with the other measures it doesn't work the way I expect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table "Output" as
           select *, median(quantity) as median, PCTL(25,quantity) as Q1, PCTL(75,quantity) as Q3, IQR(quantity) as IQR
                    from work.documentX
group by Client, Product;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I uploaded an example with an excel sheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for you help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Federico.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 18:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365133#M23928</guid>
      <dc:creator>jfcubells</dc:creator>
      <dc:date>2017-06-07T18:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating IQR, Q1 and Q3 with a group by</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365135#M23929</link>
      <description>&lt;P&gt;PROC UNIVARIATE with a BY statement ought to give you the values you want&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 18:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365135#M23929</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-07T18:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating IQR, Q1 and Q3 with a group by</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365141#M23930</link>
      <description>&lt;P&gt;Or proc means/summary requesting Q1, Q3 and Qrange with CLASS statement, or Proc Tabulate with the same statistics with the group by as class variables.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 18:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365141#M23930</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-07T18:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating IQR, Q1 and Q3 with a group by</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365150#M23931</link>
      <description>&lt;P&gt;What version of SAS do you have?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AFAIK percentiles/median don't work in SQL until at least SAS 9.4 and I'm not even sure PCTLs work as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would strongly suggest comparing results to PROC MEANS/UNIVARIATE at minimum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see/use how I've done this here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/31316a678433a1db8136" target="_blank"&gt;https://gist.github.com/statgeek/31316a678433a1db8136&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 19:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/365150#M23931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-07T19:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating IQR, Q1 and Q3 with a group by</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/366687#M24001</link>
      <description>&lt;P&gt;Thanks a lot for all the help you all gave me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final solution was this one:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc MEANS Data=work.dataset
n median qrange p25 p75;
var Quantity;
class Client Product;
ods output summary=ranges;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 16:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculating-IQR-Q1-and-Q3-with-a-group-by/m-p/366687#M24001</guid>
      <dc:creator>jfcubells</dc:creator>
      <dc:date>2017-06-13T16:30:13Z</dc:date>
    </item>
  </channel>
</rss>

