<?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 take number with decimals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556886#M155174</link>
    <description>&lt;P&gt;So&amp;nbsp;&lt;SPAN&gt;89.561234 would result in 89.5, no rounding here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    l=floor(log10(num));
    if l&amp;gt;2 then 
        y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.)/100;
    else if l=2 then y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.)/10;
    else if l=1 then y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.);
    drop l;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2019 17:21:17 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-05-07T17:21:17Z</dc:date>
    <item>
      <title>how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556860#M155156</link>
      <description>&lt;P&gt;data y ;&lt;BR /&gt;input num ;&lt;BR /&gt;cards ;&lt;BR /&gt;3445.356&lt;BR /&gt;666745.546&lt;BR /&gt;333.6756&lt;BR /&gt;36356356.345&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;how to do like take num variable (only integers)&amp;nbsp; a like see below example remove decimals with in number we have form the decimals and finally variable should be numeric datatype&lt;/P&gt;&lt;P&gt;34.45&lt;/P&gt;&lt;P&gt;66.67&lt;/P&gt;&lt;P&gt;33.3&lt;/P&gt;&lt;P&gt;36.35&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556860#M155156</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-05-07T16:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556870#M155164</link>
      <description>&lt;P&gt;So let's see if my understanding is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the first two digits of a long number to be in the result to the left of the decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you want the next two digits of a long number to be in the result to the right of the decimal point, but if the original number doesn't have two more digits before the decimal point, then the result should only have the next one digit to the right of the decimal point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes or no?&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556870#M155164</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-07T16:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556873#M155165</link>
      <description>Put it into scientific notation, convert to character and take the first portion.</description>
      <pubDate>Tue, 07 May 2019 16:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556873#M155165</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-07T16:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556875#M155166</link>
      <description>For example number is 8956.1234&lt;BR /&gt;Finally should be like 89.56&lt;BR /&gt;Don't take decimals&lt;BR /&gt;</description>
      <pubDate>Tue, 07 May 2019 17:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556875#M155166</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-05-07T17:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556876#M155167</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data y ;&lt;BR /&gt;input num ;&lt;BR /&gt;cards ;&lt;BR /&gt;3445.356&lt;BR /&gt;666745.546&lt;BR /&gt;333.6756&lt;BR /&gt;36356356.345&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;how to do like take num variable (only integers)&amp;nbsp; a like see below example remove decimals with in number we have form the decimals and finally variable should be numeric datatype&lt;/P&gt;
&lt;P&gt;34.45&lt;/P&gt;
&lt;P&gt;66.67&lt;/P&gt;
&lt;P&gt;33.3&lt;/P&gt;
&lt;P&gt;36.35&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please provide a clearer example of START and End desired result. And possibly the steps you use to get the result.&lt;/P&gt;
&lt;P&gt;Your second list of random numbers includes decimals, so I am not sure what you mean by "only integers" or what you have done as there are apparently different rules applied to different ranges of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the integer portion of a numeric value using the INT or INTZ functions depending on how you want to treat very small decimal differences from the integer.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 17:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556876#M155167</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-07T17:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556878#M155169</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;For example number is 8956.1234&lt;BR /&gt;Finally should be like 89.56&lt;BR /&gt;Don't take decimals&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, fine, that's clear. If the number is 895.61234, we should ignore the numbers to the right of the decimal point and produce the result 89.5? What if the original number is 89.561234??&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 17:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556878#M155169</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-07T17:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556879#M155170</link>
      <description>Any number first remove decimals next take number like if&lt;BR /&gt;Total digits 5 then 12.34&lt;BR /&gt;total digits 4 then 12.34&lt;BR /&gt;Total digits 3 then 12.3&lt;BR /&gt;Total digits 2 then 12.00&lt;BR /&gt;</description>
      <pubDate>Tue, 07 May 2019 17:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556879#M155170</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-05-07T17:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556883#M155173</link>
      <description>Finally it should be 89.5 that's it&lt;BR /&gt;</description>
      <pubDate>Tue, 07 May 2019 17:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556883#M155173</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2019-05-07T17:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556886#M155174</link>
      <description>&lt;P&gt;So&amp;nbsp;&lt;SPAN&gt;89.561234 would result in 89.5, no rounding here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    l=floor(log10(num));
    if l&amp;gt;2 then 
        y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.)/100;
    else if l=2 then y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.)/10;
    else if l=1 then y=input(substrn(num,1,2),2.)+input(substrn(num,3,2),2.);
    drop l;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 17:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556886#M155174</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-07T17:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556897#M155182</link>
      <description>&lt;P&gt;Can we ask why?&amp;nbsp; Is it possible to fix the confusion at some earlier step in the process?&lt;/P&gt;
&lt;P&gt;So use INT() to get integer part. Use PUT to convert it it to text. Left align it. Convert trailing spaces to zeros. Read first 4 digits using implied decimal point.&lt;/P&gt;
&lt;P&gt;Or use LOG10() to find the magnitude of the number and divide by the appropriate power of 10.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;
  input num ;
  want=input(translate(put(int(num),32.-L),'0',' '),4.2);
  want2=int(int(num)/10**(int(log10(num))-3))/100;
cards ;
3445.356
666745.546
333.6756
36356356.345
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs            num     want    want2

 1         3445.36    34.45    34.45
 2       666745.55    66.67    66.67
 3          333.68    33.30    33.30
 4     36356356.35    36.35    36.35&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 18:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/556897#M155182</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-07T18:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/557103#M155262</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture fmt
 low-high='000000.99';
run;
data y ;
input num ;
n=(ceil(log10(num))-2);
want=int(num)/(10**n);
format want fmt.;
cards ;
3445.356
666745.546
333.6756
36356356.345
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 May 2019 13:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/557103#M155262</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-05-08T13:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: how take number with decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/557221#M155305</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Any number first remove decimals next take number like if&lt;BR /&gt;Total digits 5 then 12.34&lt;BR /&gt;total digits 4 then 12.34&lt;BR /&gt;Total digits 3 then 12.3&lt;BR /&gt;Total digits 2 then 12.00&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And how does the above relate to your posted value of&lt;/P&gt;
&lt;P&gt;36356356.345&lt;/P&gt;
&lt;P&gt;which would seem to have 8 "total digits" (in your terminology, not mine)&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 18:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-take-number-with-decimals/m-p/557221#M155305</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-08T18:07:55Z</dc:date>
    </item>
  </channel>
</rss>

