<?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 increase decimal, or add decimal to an integer? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515717#M139204</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239423"&gt;@d6k5d3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that &lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; is a &lt;EM&gt;numeric variable in an existing SAS dataset&lt;/EM&gt;&amp;nbsp;(let's call it HAVE) you don't&amp;nbsp;need to modify the &lt;EM&gt;values&lt;/EM&gt; of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; in order to change their appearance. As you know, 4556=4556.00000 mathematically and SAS would store both values in exactly the same way internally. The same is true for the other values (0.56=0.56000, etc.*).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p0hix48i0fau1wn1vupa38achpt3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;SAS &lt;EM&gt;formats&lt;/EM&gt;&lt;/A&gt; are the right tool for changing the way how a value is displayed, printed or written to a file. For example, you can display a numeric value with the format named &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n1n7bmvs1brl23n1dj9cbzau39df.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;17.5&lt;/A&gt; in order to get 5 decimal places and up to 17 characters (including all digits, the decimal point and a minus sign, if any) in total. So, this would be sufficient for your example values (which require only up to 16 characters). Similarly, the format F32.5 (which is an alias for 32.5) suggested by &lt;STRONG&gt;Ksharp&lt;/STRONG&gt; would reserve a width of 32 (rather than 17) characters for the output field. (Try the PROC PRINT step&amp;nbsp;below with both formats, one at a time, to see the difference.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can apply such formats temporarily in the code you are using to display the values, e.g., in a PROC PRINT step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
format yyzz 17.5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Alternatively, you can associate the format permanently with variable &lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; so that the above PROC PRINT step would&amp;nbsp;produce the same result without the FORMAT statement.&amp;nbsp;(This is what &lt;STRONG&gt;Ksharp&lt;/STRONG&gt; did when he created dataset HAVE.) To do this, you can use the same&amp;nbsp;FORMAT statement in a DATA step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set have;
format yyzz 17.5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;or, more efficiently, in a PROC DATASETS step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work nolist;
modify have;
format yyzz 17.5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The latter has the advantage that no data are read or written, but only one variable attribute is added (a change only in "metadata").&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;* (Sadly this is not quite true &lt;EM&gt;in general&lt;/EM&gt;: There are exceptional cases where SAS stores numeric values which are mathematically equal in slightly different ways. But this is a more advanced topic.)&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 24 Nov 2018 11:46:50 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-24T11:46:50Z</dc:date>
    <item>
      <title>How to increase decimal, or add decimal to an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515713#M139201</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a column like the one below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;yyzz&lt;/U&gt;&lt;/P&gt;&lt;P&gt;4556&lt;/P&gt;&lt;P&gt;0.56&lt;/P&gt;&lt;P&gt;0.375&lt;/P&gt;&lt;P&gt;1223456.5&lt;/P&gt;&lt;P&gt;9673000000&lt;/P&gt;&lt;P&gt;1.24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to maintain 5 decimal places with each number. So my result should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;yyzz&lt;/U&gt;&lt;/P&gt;&lt;P&gt;4556.00000&lt;/P&gt;&lt;P&gt;0.56000&lt;/P&gt;&lt;P&gt;0.37500&lt;/P&gt;&lt;P&gt;1223456.50000&lt;/P&gt;&lt;P&gt;9673000000.00000&lt;/P&gt;&lt;P&gt;1.24000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should be the code to get this desired outcome? Struggled a lot myself, but no help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking forward to your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Nov 2018 08:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515713#M139201</guid>
      <dc:creator>d6k5d3</dc:creator>
      <dc:date>2018-11-24T08:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase decimal, or add decimal to an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515715#M139202</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input yyzz;
format yyzz f32.5;
cards;
4556
0.56
0.375
1223456.5
9673000000
1.24
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Nov 2018 10:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515715#M139202</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-24T10:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase decimal, or add decimal to an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515716#M139203</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input yyzz;
format yyzz f32.5;
cards;
4556
0.56
0.375
1223456.5
9673000000
1.24
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 24 Nov 2018 11:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515716#M139203</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-24T11:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase decimal, or add decimal to an integer?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515717#M139204</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239423"&gt;@d6k5d3&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that &lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; is a &lt;EM&gt;numeric variable in an existing SAS dataset&lt;/EM&gt;&amp;nbsp;(let's call it HAVE) you don't&amp;nbsp;need to modify the &lt;EM&gt;values&lt;/EM&gt; of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; in order to change their appearance. As you know, 4556=4556.00000 mathematically and SAS would store both values in exactly the same way internally. The same is true for the other values (0.56=0.56000, etc.*).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p0hix48i0fau1wn1vupa38achpt3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;SAS &lt;EM&gt;formats&lt;/EM&gt;&lt;/A&gt; are the right tool for changing the way how a value is displayed, printed or written to a file. For example, you can display a numeric value with the format named &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n1n7bmvs1brl23n1dj9cbzau39df.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;17.5&lt;/A&gt; in order to get 5 decimal places and up to 17 characters (including all digits, the decimal point and a minus sign, if any) in total. So, this would be sufficient for your example values (which require only up to 16 characters). Similarly, the format F32.5 (which is an alias for 32.5) suggested by &lt;STRONG&gt;Ksharp&lt;/STRONG&gt; would reserve a width of 32 (rather than 17) characters for the output field. (Try the PROC PRINT step&amp;nbsp;below with both formats, one at a time, to see the difference.)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can apply such formats temporarily in the code you are using to display the values, e.g., in a PROC PRINT step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have;
format yyzz 17.5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Alternatively, you can associate the format permanently with variable &lt;FONT face="courier new,courier"&gt;yyzz&lt;/FONT&gt; so that the above PROC PRINT step would&amp;nbsp;produce the same result without the FORMAT statement.&amp;nbsp;(This is what &lt;STRONG&gt;Ksharp&lt;/STRONG&gt; did when he created dataset HAVE.) To do this, you can use the same&amp;nbsp;FORMAT statement in a DATA step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set have;
format yyzz 17.5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;or, more efficiently, in a PROC DATASETS step:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets lib=work nolist;
modify have;
format yyzz 17.5;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The latter has the advantage that no data are read or written, but only one variable attribute is added (a change only in "metadata").&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;* (Sadly this is not quite true &lt;EM&gt;in general&lt;/EM&gt;: There are exceptional cases where SAS stores numeric values which are mathematically equal in slightly different ways. But this is a more advanced topic.)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Nov 2018 11:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-increase-decimal-or-add-decimal-to-an-integer/m-p/515717#M139204</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-24T11:46:50Z</dc:date>
    </item>
  </channel>
</rss>

