<?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 select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708416#M217714</link>
    <description>&lt;P&gt;Define "round figures".&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 11:57:24 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-12-28T11:57:24Z</dc:date>
    <item>
      <title>How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708413#M217711</link>
      <description>I have a list of transaction amounts. From there I want to select only those observations where the transaction amount is in round figure, like 250, 500, 1000, 2000, etc.&lt;BR /&gt;If I take only cases where mod(x,10)=0 then it also keeps transactions like 1410, 1280, but I do not want these, I want round figures like 250, 300, 500,etc.&lt;BR /&gt;How do I proceed? I am using SAS 9.4.</description>
      <pubDate>Mon, 28 Dec 2020 11:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708413#M217711</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2020-12-28T11:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708414#M217712</link>
      <description>How about :  mod(x,50)=0</description>
      <pubDate>Mon, 28 Dec 2020 11:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708414#M217712</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-12-28T11:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708416#M217714</link>
      <description>&lt;P&gt;Define "round figures".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 11:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708416#M217714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-28T11:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708444#M217718</link>
      <description>&lt;P&gt;Editted note:&amp;nbsp; Apologies:&amp;nbsp; I have misunderstood your problem.&amp;nbsp; You can ignore everything below.&amp;nbsp; I leave it for the curious.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You apparently want all values that are multiple of 250 times 2 to an integer power.&amp;nbsp; I.e.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;x=250 =&amp;nbsp; &amp;nbsp;250* (2**0)&lt;/LI&gt;
&lt;LI&gt;x=500 =&amp;nbsp; &amp;nbsp;250* (2**1)&lt;/LI&gt;
&lt;LI&gt;x=1000 = 250* (2**2)&lt;/LI&gt;
&lt;LI&gt;etc.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So, if the log2 of (x/250) is a non-negative integer, you would satisfy this requirement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do x=1 to 16000; output; end;
run;

data want;
  set have;
  where log2(x/250) = floor(log2(x/250));
  where also log2(x/250)&amp;gt;=0;
  put x=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, at some point there may be a numeric precision issue, but it works correctly at least up to 250*(2**20).&amp;nbsp; When I replaced 16000 above by 250*(2**20), I got the log below, taking about 40 seconds to run:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;6890   data have;
6891     do x=1 to 250*(2**20); output; end;
6892   run;

NOTE: The data set WORK.HAVE has 262144000 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           5.01 seconds
      cpu time            5.00 seconds


6893
6894   data want;
6895     set have;
6896     where log2(x/250) = floor(log2(x/250));
6897     where also log2(x/250)&amp;gt;=0;
NOTE: WHERE clause has been augmented.
6898     put x=;
6899   run;

x=250
x=500
x=1000
x=2000
x=4000
x=8000
x=16000
x=32000
x=64000
x=128000
x=256000
x=512000
x=1024000
x=2048000
x=4096000
x=8192000
x=16384000
x=32768000
x=65536000
x=131072000
x=262144000
NOTE: There were 21 observations read from the data set WORK.HAVE.
      WHERE (LOG2((x/250))=FLOOR(LOG2((x/250)))) and (LOG2((x/250))&amp;gt;=0);
NOTE: The data set WORK.WANT has 21 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           35.17 seconds
      cpu time            35.15 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And why do I know this is correct?&amp;nbsp; Because there are 21 resulting observations, representing powers of 2 from 0 through 20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a faster way: make a list of desired value in an array.&amp;nbsp; Then you don't have to bother with generating logs.&amp;nbsp; The data step below took 10 seconds (vs 35 seconds above):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  array testvalues {0:20} _temporary_;
  if _n_=1 then do p=0 to 20;
    testvalues{p}=250*(2**p);
  end;

  set have;
  if  whichn(x,of testvalues{*});
  put x=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 17:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708444#M217718</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-28T17:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708445#M217719</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You apparently want all values that are multiple of 250 times 2 to an integer power.&amp;nbsp; I.e.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;x=250 =&amp;nbsp; &amp;nbsp;250* (2**0)&lt;/LI&gt;
&lt;LI&gt;x=500 =&amp;nbsp; &amp;nbsp;250* (2**1)&lt;/LI&gt;
&lt;LI&gt;x=1000 = 250* (2**2)&lt;/LI&gt;
&lt;LI&gt;etc.&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Except that the OP&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/361528"&gt;@Shradha1&lt;/a&gt; stated in his/her text (which doesn't agree with the title, and I always find that confusing) that he/she wants to select 300 as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which brings me back to my comment. The OP needs to define "round figures".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 17:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708445#M217719</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-28T17:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708446#M217720</link>
      <description>Yes, just realized that.  I put a disclaimer at the top of my note.   THX.</description>
      <pubDate>Mon, 28 Dec 2020 17:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708446#M217720</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-28T17:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708585#M217782</link>
      <description>&lt;P&gt;I agree the definition of "round" is not standard.&amp;nbsp; What I think is being described is a rounding, in terms of scientific notation, where the&amp;nbsp;&lt;A title="Significand" href="https://en.wikipedia.org/wiki/Significand" target="_blank" rel="noopener"&gt;significand&lt;/A&gt;&amp;nbsp;or&amp;nbsp;mantissa is rounded to the nearest 0.5.&amp;nbsp; If that is so, I find the mantissa, round, and convert back to normal, non-scientific-notation form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RandBetween(min, max);
   (&amp;amp;min + floor((1+&amp;amp;max-&amp;amp;min)*rand("uniform")))
%mend;

data want ;
  do i = 1 to 10;
    p=%RandBetween(2,nobs);
    set SASHELP.GEOEXM(Keep=last) point=p nobs=nobs;
    last_power = 10**floor(LOG10(last));
      drop last_power ;
    last_new = round(last,0.5*last_power);
    output;
  end;
  stop;
proc sort;
  by last;
data want;
  set want;
  i=_N_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;i	Last	last_new&lt;/STRONG&gt;
1	6187	6000
2	9933	10000
3	15660	15000
4	36662	35000
5	45234	45000
6	47104	45000
7	64690	65000
8	72860	75000
9	76560	75000
10	124603	100000&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 17:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708585#M217782</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2020-12-29T17:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708593#M217787</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;What I think is being described is a rounding, in terms of scientific notation, where the&amp;nbsp;&lt;A title="Significand" href="https://en.wikipedia.org/wiki/Significand" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;significand&lt;/A&gt;&amp;nbsp;or&amp;nbsp;mantissa is rounded to the nearest 0.5.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How can you tell that from the contradictory problem explanation?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 16:52:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708593#M217787</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-29T16:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to select only round figures like 250, 500, 1000, 1500, 2000 etc from a list of numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708595#M217788</link>
      <description>&lt;P&gt;A problem explanation than can be contradictory implies a problem that was written in a mathematical logic.&amp;nbsp; Our friend gave us an example of what they are looking for.&amp;nbsp; I formed an opinion of what they wanted, and offered an my best educated guess.&amp;nbsp; I though it was a better answer than Mr.&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;, before he retracted it.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 17:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-select-only-round-figures-like-250-500-1000-1500-2000-etc/m-p/708595#M217788</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2020-12-29T17:10:59Z</dc:date>
    </item>
  </channel>
</rss>

