<?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: Rounding a character value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792789#M254027</link>
    <description>&lt;P&gt;Since you want to discard information (everything after the first decimal), these numbers seem to be real numeric values and not some type of category. In this case, you are better off omitting the re-conversion to character and store the data in a numeric variable with a format that has one digit after the decimal dot.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 08:50:32 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-27T08:50:32Z</dc:date>
    <item>
      <title>Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792780#M254018</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a rounding issue and here is the simplified code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;format c $5.;&lt;BR /&gt;b= '1.04';&lt;BR /&gt;c = left(round(b, 0.1));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output: c= 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cornelis_0-1643267204876.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67913iAF6B3723362CB82B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cornelis_0-1643267204876.png" alt="Cornelis_0-1643267204876.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, the desired output must be&lt;SPAN&gt;&amp;nbsp;1.0 not 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;It is possible to apply different SAS function as solution to add '.0' to 1 if it is too sharply rounded, but I wonder whether is an easy solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cornelis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 07:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792780#M254018</guid>
      <dc:creator>Cornelis</dc:creator>
      <dc:date>2022-01-27T07:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792782#M254020</link>
      <description>&lt;P&gt;how about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   b = '1.04';
   c = put(round(input(b, 8.2), .1), 8.1 -l);
   put b = / c = ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jan 2022 07:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792782#M254020</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-27T07:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792783#M254021</link>
      <description>&lt;P&gt;The real question here is: why are numbers used for calculations stored in a character variable, which makes handling them unnecessarily hard?&lt;/P&gt;
&lt;P&gt;Keep in mind that computers should make your life easier with every step, not harder.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792783#M254021</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-27T08:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792785#M254023</link>
      <description>&lt;P&gt;Hi Peter,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a reasonable good solution, the put statement in combination with format can be quickly applied in the existing programming code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cornelis&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792785#M254023</guid>
      <dc:creator>Cornelis</dc:creator>
      <dc:date>2022-01-27T08:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792786#M254024</link>
      <description>&lt;P&gt;Dear Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The situation is less easy.&lt;/P&gt;
&lt;P&gt;I received a large set of data from a database system and the column contains the next value in character:&lt;/P&gt;
&lt;P&gt;0.12&lt;/P&gt;
&lt;P&gt;0.6&lt;/P&gt;
&lt;P&gt;93.6&lt;/P&gt;
&lt;P&gt;93.0&lt;/P&gt;
&lt;P&gt;11200&lt;/P&gt;
&lt;P&gt;25.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values (characters) in a column of a table are all correctly rounded because it depends on the level of analytical instrument.&lt;/P&gt;
&lt;P&gt;One instrument rounds with no digit, the other with 1 or 2. That is therefore the reason why I get dataset with character format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792786#M254024</guid>
      <dc:creator>Cornelis</dc:creator>
      <dc:date>2022-01-27T08:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792789#M254027</link>
      <description>&lt;P&gt;Since you want to discard information (everything after the first decimal), these numbers seem to be real numeric values and not some type of category. In this case, you are better off omitting the re-conversion to character and store the data in a numeric variable with a format that has one digit after the decimal dot.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-character-value/m-p/792789#M254027</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-27T08:50:32Z</dc:date>
    </item>
  </channel>
</rss>

