<?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: Proc Rank in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832843#M329229</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3492"&gt;@JosvanderVelden&lt;/a&gt;&amp;nbsp; There is no format or length has been applied to the variable&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV. Then how the values will differ internally?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's called round-off error, or machine precision, or machine epsilon. Some numbers cannot be represented exactly in binary digital computers.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Machine_epsilon" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Machine_epsilon&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;How can we see the actual value of SHIPPED_YTD_GSV. without any rounding? I want to see the difference between the two values as I shown in post.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assign format best32. to that variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no format or length has been applied to the variable SHIPPED_YTD_GSV. Then how the values will differ internally?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even I did checked the source variable which creates SHIPPED_YTD_GSV and there also no format applied.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not try the suggestion to round off the variable to 2 digits.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 09:59:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-09-12T09:59:38Z</dc:date>
    <item>
      <title>Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832831#M329222</link>
      <description>&lt;P&gt;I'd like to understand why I got the two different rank for the same&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV. I want the same rank 2247 to be displayed for both the records.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE tabindex="0" width="366" data-is-focusable="true"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;SPAN&gt;MATERIAL&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;SPAN&gt;SHIPPED_YTD_GSV&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;SPAN&gt;SHIPPED_YTD_GSV_RANK&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;3800020398&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;31147.2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;2247&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;3800025512&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;31147.2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;SPAN&gt;2248&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code which I used is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table work.tst_ytd_gsv as
select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MATERIAL,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum(SHIPPED_GSV) as SHIPPED_YTD_GSV
from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;work.all_data
where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FISC_YR = 2021
group by&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MATERIAL;
quit;

proc rank data=work.tst_ytd_gsv out=work.tst_ytd_gsv_rank ties=dense descending;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var SHIPPED_YTD_GSV;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ranks SHIPPED_YTD_GSV_RANK;
run;&lt;/PRE&gt;
&lt;P&gt;I did applied the format 12.2 to the variable&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV but still the same issue.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 08:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832831#M329222</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-09-12T08:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832834#M329224</link>
      <description>&lt;P&gt;Because&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV are not exactly equal. It is not enough to apply some format to the values, the internal 8 byte value is still the same.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One way is to round the&amp;nbsp;SHIPPED_YTD_GSV value to 2 integers using the Round Function.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 08:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832834#M329224</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-12T08:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832836#M329226</link>
      <description>The unformatted values in the dataset must be different.&lt;BR /&gt;Proc rank does show the same rank if the values are exactly the same.&lt;BR /&gt;See the example1 from the documentation: &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n18s1uw2tqvtxdn1chay1qq1jke6.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n18s1uw2tqvtxdn1chay1qq1jke6.htm&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Sep 2022 08:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832836#M329226</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2022-09-12T08:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832840#M329227</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3492"&gt;@JosvanderVelden&lt;/a&gt;&amp;nbsp; There is no format or length has been applied to the variable&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV. Then how the values will differ internally?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Even I did checked the source variable which creates&amp;nbsp;SHIPPED_YTD_GSV and there also no format applied.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How can we see the actual value of&amp;nbsp;SHIPPED_YTD_GSV. without any rounding? I want to see the difference between the two values as I shown in post.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 09:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832840#M329227</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-09-12T09:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832841#M329228</link>
      <description>&lt;P&gt;If you want to verify that there is a difference between the two computed values, try applying the &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/leforinforref/n0ueabv26pr2fwn19uxk2f4bf10y.htm" target="_self"&gt;Hex16. Format&lt;/A&gt; in the SQL step and check the values. Do they differ?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 09:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832841#M329228</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-12T09:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832843#M329229</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3492"&gt;@JosvanderVelden&lt;/a&gt;&amp;nbsp; There is no format or length has been applied to the variable&amp;nbsp;&lt;SPAN&gt;SHIPPED_YTD_GSV. Then how the values will differ internally?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It's called round-off error, or machine precision, or machine epsilon. Some numbers cannot be represented exactly in binary digital computers.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://en.wikipedia.org/wiki/Machine_epsilon" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/Machine_epsilon&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;How can we see the actual value of SHIPPED_YTD_GSV. without any rounding? I want to see the difference between the two values as I shown in post.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assign format best32. to that variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no format or length has been applied to the variable SHIPPED_YTD_GSV. Then how the values will differ internally?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even I did checked the source variable which creates SHIPPED_YTD_GSV and there also no format applied.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not try the suggestion to round off the variable to 2 digits.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 09:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/832843#M329229</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-12T09:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834122#M329786</link>
      <description>If you want to get background information about numeric precision with SAS please visit: &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm&lt;/A&gt;</description>
      <pubDate>Mon, 19 Sep 2022 15:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834122#M329786</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2022-09-19T15:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834131#M329794</link>
      <description>&lt;P&gt;Just to add a specific consideration for your example 31147.2:&lt;/P&gt;
&lt;P&gt;Randomly pick a number &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; from the 3,114,719-element set {0.01, 0.02, 0.03, ..., 31147,18, 31147.19} and compute &lt;FONT face="courier new,courier"&gt;y=31147.2-x&lt;/FONT&gt; by hand or with a pocket calculator.&lt;/P&gt;
&lt;P&gt;What is the probability that, "surprisingly,"&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;x+y &lt;EM&gt;ne&lt;/EM&gt; 31147.2&lt;/FONT&gt; in SAS 9.4M5 under Windows? Have a guess.&lt;/P&gt;
&lt;LI-SPOILER&gt;Answer: 37.33%.&lt;BR /&gt;
&lt;PRE&gt;309   %let n=3114720;
310
311   data _null_;
312   do k=1 to &amp;amp;n-1;
313     u+(k/100+(&amp;amp;n-k)/100 ne &amp;amp;n/100);
314   end;
315   p=u/(k-1);
316   put p= percent8.2;
317   run;

&lt;STRONG&gt;p=37.33%&lt;/STRONG&gt;
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.15 seconds


318
319   /* Examples: */
320
321   data _null_;
322   s0=31147.2;
323   s1=&lt;STRONG&gt;10001.35+21145.85&lt;/STRONG&gt;;
324   s2=10001.36+21145.84;
325   s3=&lt;STRONG&gt;10001.37+21145.83&lt;/STRONG&gt;;
326   put (s:)(=hex16./);
327   run;

s0=40DE6ACCCCCCCCCD
s1=&lt;STRONG&gt;40DE6ACCCCCCCCC&lt;FONT color="#FF0000"&gt;C&lt;/FONT&gt;&lt;/STRONG&gt;
s2=40DE6ACCCCCCCCCD
s3=&lt;STRONG&gt;40DE6ACCCCCCCCC&lt;FONT color="#FF0000"&gt;E&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Mon, 19 Sep 2022 17:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834131#M329794</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-19T17:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Rank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834158#M329809</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.tst_ytd_gsv as
select         MATERIAL,
            round(sum(SHIPPED_GSV), 0.01) as SHIPPED_YTD_GSV
from        work.all_data
where        FISC_YR = 2021
group by    MATERIAL;
quit;

proc rank data=work.tst_ytd_gsv out=work.tst_ytd_gsv_rank ties=dense descending;
    var SHIPPED_YTD_GSV;
    ranks SHIPPED_YTD_GSV_RANK;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What happens if you do it as above?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you say you round to 12.2 -&amp;gt; which is two decimal places, but show only one decimal place. The second decimal is likely different.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 19:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Rank/m-p/834158#M329809</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-19T19:11:57Z</dc:date>
    </item>
  </channel>
</rss>

