<?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 How to pull out each place of a decimal value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63684#M18110</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a math problem. Here is one way using powers of 10, INT and MOD functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put x= @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do place=1 to 3 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digit=mod(int(x*10**place),10);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put digit= @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;.003&lt;/P&gt;&lt;P&gt;.123&lt;/P&gt;&lt;P&gt;12.345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it starting from 0 or minus one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Sep 2011 22:10:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-09-12T22:10:44Z</dc:date>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63682#M18108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to get the individual numbers after the decimal place and i'm not sure how to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say I have .003&amp;nbsp; I want to pull out the first 0 in d1 and the second to d2 and 3 into d3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if the mod function would be the way to go or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 20:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63682#M18108</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2011-09-12T20:43:09Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63683#M18109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There may be an easier way, but you can always use brute force. e.g.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; d1=int(x*10);&lt;/P&gt;&lt;P&gt;&amp;nbsp; d2=int(x*100-(int(x*10)*10));&lt;/P&gt;&lt;P&gt;&amp;nbsp; d3=int(x*1000-(int(x*100)*10));&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;.003&lt;/P&gt;&lt;P&gt;.123&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 21:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63683#M18109</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-09-12T21:56:31Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63684#M18110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a math problem. Here is one way using powers of 10, INT and MOD functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put x= @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do place=1 to 3 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digit=mod(int(x*10**place),10);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put digit= @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;.003&lt;/P&gt;&lt;P&gt;.123&lt;/P&gt;&lt;P&gt;12.345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it starting from 0 or minus one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2011 22:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63684#M18110</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-09-12T22:10:44Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63685#M18111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for both the answers.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom how can I put the answer in 3 seperate columns for each row?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 12:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63685#M18111</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2011-09-13T12:54:45Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63686#M18112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using Tom's method is the following what you are looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array digit(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do place=1 to 3 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digit(place)=mod(int(x*10**place),10);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;.003&lt;/P&gt;&lt;P&gt;.123&lt;/P&gt;&lt;P&gt;12.345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 13:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63686#M18112</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-09-13T13:44:53Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63687#M18113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a negative number this should have one minor flaw.&amp;nbsp; I cannot test but I believe that if you have say -1.003 then using this method digit3=-3 which you probably do not want. You will probably want to account for this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 15:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63687#M18113</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-13T15:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63688#M18114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FriedEgg,&amp;nbsp; Tom's method correctly deals with negative numbers .. it simply keeps the minus sign.&amp;nbsp; If the minus sign isn't desired by the OP, a simple solution would be to add an abs function.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array digit(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do place=1 to 3 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; digit(place)=abs(mod(int(x*10**place),10));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;.003&lt;/P&gt;&lt;P&gt;.123&lt;/P&gt;&lt;P&gt;12.345&lt;/P&gt;&lt;P&gt;-12.345&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 16:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63688#M18114</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-09-13T16:05:29Z</dc:date>
    </item>
    <item>
      <title>How to pull out each place of a decimal value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63689#M18115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you to everyone for your suggestions.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used Tom and Art's suggestions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Sep 2011 16:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-pull-out-each-place-of-a-decimal-value/m-p/63689#M18115</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2011-09-13T16:12:12Z</dc:date>
    </item>
  </channel>
</rss>

