<?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: calculate 75 percentile of a variable using proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926913#M364799</link>
    <description>&lt;P&gt;Just to add the explanation &lt;EM&gt;why&lt;/EM&gt; your approach doesn't work and you should use a different procedure, as others have already suggested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1m9jbizvp3gwsn1lwf0snogk53i.htm" target="_blank" rel="noopener"&gt;PCTL function&lt;/A&gt;&amp;nbsp;(unlike the MEDIAN function) is not among the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n123fsko39j44pn16zlt087e1m2h.htm" target="_blank" rel="noopener"&gt;PROC SQL summary functions&lt;/A&gt;. Hence, it is not applied to the &lt;EM&gt;variable&lt;/EM&gt; (&lt;EM&gt;column&lt;/EM&gt;)&amp;nbsp;&lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt;, but to the single value of &lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt; in each &lt;EM&gt;observation&lt;/EM&gt; (&lt;EM&gt;row&lt;/EM&gt;). But for any non-missing numeric value the trivial equality&amp;nbsp;&lt;FONT face="courier new,courier"&gt;pctl(75, var)=var&lt;/FONT&gt; holds. So, your output dataset MT contains variable &lt;FONT face="courier new,courier"&gt;cou&lt;/FONT&gt;&amp;nbsp;and basically a copy of variable &lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt;, named &lt;FONT face="courier new,courier"&gt;var_p75&lt;/FONT&gt;, from the input dataset CHECK_1. In particular, it is not aggregated at all, as you have noticed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must have received a warning in the log about the absence of a summary function:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#008000"&gt;WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT clause nor the optional HAVING clause of the associated
         table-expression referenced a summary function.&lt;/FONT&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 May 2024 15:32:19 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-05-03T15:32:19Z</dc:date>
    <item>
      <title>calculate 75 percentile of a variable using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926889#M364785</link>
      <description>&lt;P&gt;I tried ("cou" is 1,2,3,4,5.....; "var" is continuous variable with decimal points):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table mt as
    select cou,
           pctl(75, var) as var_p75
    from check_1
    group by cou;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it returns me with multiple rows per cou.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 12:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926889#M364785</guid>
      <dc:creator>zihdonv19</dc:creator>
      <dc:date>2024-05-03T12:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: calculate 75 percentile of a variable using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926891#M364787</link>
      <description>&lt;P&gt;SQL is not the best tool for this job.&lt;/P&gt;
&lt;P&gt;I'd use Proc Univariate, here is nice example:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_univariate_examples08.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_univariate_examples08.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 13:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926891#M364787</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-05-03T13:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: calculate 75 percentile of a variable using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926907#M364797</link>
      <description>&lt;P&gt;While SQL might or might not be able to do this, it is a lot more programming than PROC UNIVARIATE/PROC MEANS/PROC SUMMARY and of course SAS has already tested and debugged these PROCs so you can be sure the answer is correct. If you program it yourself in SQL, I think you have to test, debug and vouch for the accuracy of what you are doing.&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 14:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926907#M364797</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-05-03T14:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculate 75 percentile of a variable using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926913#M364799</link>
      <description>&lt;P&gt;Just to add the explanation &lt;EM&gt;why&lt;/EM&gt; your approach doesn't work and you should use a different procedure, as others have already suggested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1m9jbizvp3gwsn1lwf0snogk53i.htm" target="_blank" rel="noopener"&gt;PCTL function&lt;/A&gt;&amp;nbsp;(unlike the MEDIAN function) is not among the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n123fsko39j44pn16zlt087e1m2h.htm" target="_blank" rel="noopener"&gt;PROC SQL summary functions&lt;/A&gt;. Hence, it is not applied to the &lt;EM&gt;variable&lt;/EM&gt; (&lt;EM&gt;column&lt;/EM&gt;)&amp;nbsp;&lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt;, but to the single value of &lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt; in each &lt;EM&gt;observation&lt;/EM&gt; (&lt;EM&gt;row&lt;/EM&gt;). But for any non-missing numeric value the trivial equality&amp;nbsp;&lt;FONT face="courier new,courier"&gt;pctl(75, var)=var&lt;/FONT&gt; holds. So, your output dataset MT contains variable &lt;FONT face="courier new,courier"&gt;cou&lt;/FONT&gt;&amp;nbsp;and basically a copy of variable &lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt;, named &lt;FONT face="courier new,courier"&gt;var_p75&lt;/FONT&gt;, from the input dataset CHECK_1. In particular, it is not aggregated at all, as you have noticed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must have received a warning in the log about the absence of a summary function:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#008000"&gt;WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT clause nor the optional HAVING clause of the associated
         table-expression referenced a summary function.&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 May 2024 15:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-75-percentile-of-a-variable-using-proc-sql/m-p/926913#M364799</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-05-03T15:32:19Z</dc:date>
    </item>
  </channel>
</rss>

