<?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: Format a numeric WITHOUT rounding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492733#M129536</link>
    <description>&lt;P&gt;Wow. Thank you for sharing and letting me learn something new. Can you please elaborate how that works if you a min or two ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or can you point me to a documentation that explains that&lt;/P&gt;</description>
    <pubDate>Wed, 05 Sep 2018 17:06:22 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-05T17:06:22Z</dc:date>
    <item>
      <title>Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492725#M129531</link>
      <description>&lt;P&gt;Hello all -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for a format that formats a numeric without rounding.&amp;nbsp; For example, I want to display the number 1.5 as 1 NOT 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not want to use a function to create a new variable.&amp;nbsp; I want to retain the value but want the format to use truncation rather than rounding when displaying.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this require a custom format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492725#M129531</guid>
      <dc:creator>KAZ</dc:creator>
      <dc:date>2018-09-05T16:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492728#M129532</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I do not want to use a function to create a new variable.&amp;nbsp;I want to retain the value but want the format to use truncation rather than rounding when displaying.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As always, I recommend what I think is the best and easiest solution.&amp;nbsp;The FLOOR function does exactly what you want. It retains the full value in the original variable, while creating a new truncated variable. Perhaps there's a good reason why you absolutely have to use a format for this, but I can't think of any.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492728#M129532</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-05T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492730#M129533</link>
      <description>&lt;P&gt;You can use a functions in a custom format definition:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value floor
other= [floor()];
run;

data example;
   x=1.23;
   format x floor.;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492730#M129533</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-05T16:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492733#M129536</link>
      <description>&lt;P&gt;Wow. Thank you for sharing and letting me learn something new. Can you please elaborate how that works if you a min or two ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or can you point me to a documentation that explains that&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 17:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492733#M129536</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-05T17:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492816#M129587</link>
      <description>&lt;P&gt;This is such a good answer that I hate to add anything to it.&amp;nbsp; But just note ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data might contain negative numbers, you should consider INT rather than FLOOR.&amp;nbsp; They will give different results.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 20:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492816#M129587</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-05T20:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492828#M129597</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is such a good answer that I hate to add anything to it.&amp;nbsp; But just note ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data might contain negative numbers, you should consider INT rather than FLOOR.&amp;nbsp; They will give different results.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yep. I thought about mentioning that the first time but without better examples of data didn't want to confuse the OP too much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use any function that will return a single value for target of a format. The [ ] indicate special handling as either a function or a format could be in the brackets. Useful for different ranges, as in the INT, FLOOR, CEIL, FUZZ or other function. Using the range "other" makes it the default action for the entire range of values. The function is called with no actual value in the argument, i.e. floor() because the Proc Format code will apply the current value of the variable being formatted. Note that this approach is restricted to a single value only, no functions with two or more parameters unless there is a default for everything except the first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fun part is that you can use a custom format created with Proc FCMP to do very odd things to values that are completely opaque to a user if they don't have the code for Proc FCMP. The online documentation for Proc Format includes an example where you can create conversions of Celsius to Fahrenheit temperatures or vice versa.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 15:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492828#M129597</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-06T15:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492830#M129598</link>
      <description>&lt;P&gt;Bravo! Thank you sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 21:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492830#M129598</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-05T21:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492832#M129600</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Or can you point me to a documentation that explains that&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As has been mentioned, the &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=n1eyyzaux0ze5ln1k03gl338avbj.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=de#n1eyyzaux0ze5ln1k03gl338avbj" target="_blank"&gt;Procedures Guide&lt;/A&gt; focuses on &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1gg77jyhc9s42n1f1vjyx2hsg8b.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=de" target="_blank"&gt;examples&lt;/A&gt; with user-defined functions. &lt;A href="https://www.sas.com/store/books/categories/examples/carpenter-s-guide-to-innovative-sas-techniques/prodBK_62454_en.html" target="_blank"&gt;Carpenter's Guide to Innovative SAS® Techniques&lt;/A&gt;&amp;nbsp;has a 4-page section about this topic (sect. 12.5.5, pp. 384-388) including several examples using SAS-supplied functions.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 21:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492832#M129600</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-09-05T21:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492833#M129601</link>
      <description>&lt;P&gt;Thanks a ton&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;. Much needed and appreciated!!!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 21:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/492833#M129601</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-05T21:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format a numeric WITHOUT rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/493004#M129671</link>
      <description>&lt;P&gt;PICTURE can do that either.&lt;/P&gt;
&lt;P&gt;If X is negative, you will get different result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture fmt
 0-high='00000000'
 low-&amp;lt;0='00000000'(prefix='-');
run;

data example;
   x=-123.786;
   format x fmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 13:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-a-numeric-WITHOUT-rounding/m-p/493004#M129671</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-09-06T13:20:51Z</dc:date>
    </item>
  </channel>
</rss>

