<?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: Formatting a field, removing the decimals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549328#M152409</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;No generic Rule as such. Just the decimal has to be removed from the given value.&lt;/P&gt;
&lt;P&gt;if the value is 55.55: has to be displayed as 5555 or if the value is 66.00 the value i want to output is 66.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the result can be in numeric format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That further example sounds a whole lot like "if the decimal portion is 00 then remove, else remove the decimal point"&lt;/P&gt;
&lt;P&gt;Which this may help with:&lt;/P&gt;
&lt;PRE&gt;data input_dataset;
   input srno $ bill_amt $10.;
   length mc062 $ 10;
   if index(bill_amt,'.00')&amp;gt;0 then mc062 = scan(bill_amt,1,'.');
   else if index(bill_amt,'.')&amp;gt;0 then mc062 = transtrn(bill_amt,'.',trimn(""));
datalines;
1 60.00
2 0.00
3 14.32
;
run;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Apr 2019 16:38:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-08T16:38:36Z</dc:date>
    <item>
      <title>Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549316#M152398</link>
      <description>&lt;P&gt;I am trying to format a particular field in the below format: If the value is 60.00 it has to be displayed as 60. if the value is 14.32 it has to displayed as 1432 and if it is 0.00 then output should be 0 i.e. No decimal should be Displayed.&lt;/P&gt;&lt;P&gt;Below is the datasets and the option i have tried&lt;/P&gt;&lt;P&gt;data input_dataset;&lt;BR /&gt;input srno $ bill_amt $10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 60.00&lt;BR /&gt;2 0.00&lt;BR /&gt;3 14.32&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set input_dataset;&lt;BR /&gt;format mc062 $10.;&lt;BR /&gt;mc062 = put((bill_amt ),10.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Result:&lt;/P&gt;&lt;P&gt;MC062:&lt;/P&gt;&lt;P&gt;60&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;1432&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 15:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549316#M152398</guid>
      <dc:creator>Anmolkhandelwal</dc:creator>
      <dc:date>2019-04-08T15:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549317#M152399</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to format a particular field in the below format: If the value is &lt;STRONG&gt;60.00&lt;/STRONG&gt; it has to be displayed as 60. if the value is 14.32 it has to displayed as &lt;STRONG&gt;1432&lt;/STRONG&gt; and if it is 0.00 then output should be 0 i.e. No decimal should be Displayed.&lt;/P&gt;
&lt;P&gt;Below is the datasets and the option i have tried&lt;/P&gt;
&lt;P&gt;data input_dataset;&lt;BR /&gt;input srno $ bill_amt $10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 60.00&lt;BR /&gt;2 0.00&lt;BR /&gt;3 14.32&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;set input_dataset;&lt;BR /&gt;format mc062 $10.;&lt;BR /&gt;mc062 = put((bill_amt ),10.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected Result:&lt;/P&gt;
&lt;P&gt;MC062:&lt;/P&gt;
&lt;P&gt;60&lt;/P&gt;
&lt;P&gt;0&lt;/P&gt;
&lt;P&gt;1432&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So do you have a generic rule for how to differentiate between when 60.00 is displayed as 60 and 14.32 as 1432?&lt;/P&gt;
&lt;P&gt;I could not tell what I would have to do if the value was 55.55 or 66.00 or anything else. We need an explicit generic rule unless your data only consists of those three values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you expect the result to be a numeric value or a character value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And likely if the value were numeric to start with it will be easier to implement. Also since your example code reads the values as 10 characters you might want to provide longer values if they are encountered as you may have yet more rules not yet stated if the bill_amt is something like 1,234.00&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 15:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549317#M152399</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-08T15:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549318#M152400</link>
      <description>&lt;P&gt;No generic Rule as such. Just the decimal has to be removed from the given value.&lt;/P&gt;&lt;P&gt;if the value is 55.55: has to be displayed as 5555 or if the value is 66.00 the value i want to output is 66.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result can be in numeric format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549318#M152400</guid>
      <dc:creator>Anmolkhandelwal</dc:creator>
      <dc:date>2019-04-08T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549319#M152401</link>
      <description>Check to see if the number = int(number).  &lt;BR /&gt;If it does, format it with no decimal point.  Otherwise, do.</description>
      <pubDate>Mon, 08 Apr 2019 16:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549319#M152401</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-04-08T16:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549320#M152402</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input_dataset;
input srno $ bill_amt $10.;
datalines;
1 60.00
2 0.00
3 14.32
;
run;

data want;
set input_dataset;
k=input(bill_amt,8.);
if k ne 0 then k1=k/int(k);
 want=ifn(k1 ne 1 ,k*100,k);
 drop k:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549320#M152402</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-08T16:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549321#M152403</link>
      <description>&lt;P&gt;Doesn't Work&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549321#M152403</guid>
      <dc:creator>Anmolkhandelwal</dc:creator>
      <dc:date>2019-04-08T16:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549322#M152404</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp; &amp;nbsp;Since you mentioned "&lt;SPAN&gt;the result can be in numeric format."&amp;nbsp; I have kept the result want variable as numeric.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549322#M152404</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-08T16:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549325#M152406</link>
      <description>data input_dataset;&lt;BR /&gt;input srno bill_amt ;&lt;BR /&gt;format bill_amt2 $20.;&lt;BR /&gt;if bill_amt = int(bill_amt) then bill_amt2 = put(bill_amt,10.); else bill_amt2=put(bill_amt,10.2);&lt;BR /&gt;datalines;</description>
      <pubDate>Mon, 08 Apr 2019 16:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549325#M152406</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-04-08T16:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549327#M152408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;No generic Rule as such. Just the decimal has to be removed from the given value.&lt;/P&gt;
&lt;P&gt;if the value is 55.55: has to be displayed as 5555 or if the value is 66.00 the value i want to output is 66.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the result can be in numeric format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then why would 14.32 end up as 1432 (as stated in your initial post)?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549327#M152408</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-08T16:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549328#M152409</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;No generic Rule as such. Just the decimal has to be removed from the given value.&lt;/P&gt;
&lt;P&gt;if the value is 55.55: has to be displayed as 5555 or if the value is 66.00 the value i want to output is 66.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the result can be in numeric format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That further example sounds a whole lot like "if the decimal portion is 00 then remove, else remove the decimal point"&lt;/P&gt;
&lt;P&gt;Which this may help with:&lt;/P&gt;
&lt;PRE&gt;data input_dataset;
   input srno $ bill_amt $10.;
   length mc062 $ 10;
   if index(bill_amt,'.00')&amp;gt;0 then mc062 = scan(bill_amt,1,'.');
   else if index(bill_amt,'.')&amp;gt;0 then mc062 = transtrn(bill_amt,'.',trimn(""));
datalines;
1 60.00
2 0.00
3 14.32
;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549328#M152409</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-08T16:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549330#M152410</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; &amp;nbsp;Clever as always &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You don't have blood in your veins. It's all brains. Well done!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549330#M152410</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-08T16:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549334#M152411</link>
      <description>&lt;P&gt;I don't understand why you would do this.&lt;/P&gt;
&lt;P&gt;How are you going to tell the difference between 1.23 and 123 ?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 16:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549334#M152411</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-08T16:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549424#M152442</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 20:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549424#M152442</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-08T20:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549624#M152530</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input_dataset;
input srno $ bill_amt $10.;
datalines;
1 60.00
2 0.00
3 14.32
;
run;

 

data test;
set input_dataset;
format mc062 $10.;
mc062 = compress(prxchange('s/\.0+$//',1,strip(bill_amt) ),'.');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2019 14:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/549624#M152530</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-04-09T14:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/733706#M228623</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;How do you remove decimals and insert commas for non-currency numbers?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 12:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/733706#M228623</guid>
      <dc:creator>burksmiv</dc:creator>
      <dc:date>2021-04-14T12:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a field, removing the decimals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/733708#M228624</link>
      <description>&lt;P&gt;Just change the display format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
x = 12345.789;
format x comma10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you do not want the value to be rounded, apply the INT() function first.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 12:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-field-removing-the-decimals/m-p/733708#M228624</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-14T12:56:05Z</dc:date>
    </item>
  </channel>
</rss>

