<?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: Trunc by 0.5 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955947#M373305</link>
    <description>&lt;P&gt;I think your objective can be resolved via the second argument of the ROUND function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(have,0.5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are starting out with character variable (say with length 5), then&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(input(have,5.),0.5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Jan 2025 18:06:39 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2025-01-13T18:06:39Z</dc:date>
    <item>
      <title>Trunc by 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955924#M373299</link>
      <description>&lt;P&gt;&amp;nbsp;Hi guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a quite trivial problem. I have a number which can have one decimal point and I want to "trunc it down" by 0.5 step. It means: if I have 2.2 I want 2. If I have 2.4 I want 2. If I have 2.6 I want 2.5, like shown in the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data numbers;
    input have $3. want $5.;
    datalines;
2.2 2
2.6 2.5
2.9 2.5
3.1 3
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can anyone help me please? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thanks in advance!&lt;BR /&gt;&amp;nbsp;Filip&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 15:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955924#M373299</guid>
      <dc:creator>filippo_kow</dc:creator>
      <dc:date>2025-01-13T15:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trunc by 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955926#M373300</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
x=((x-int(x))&amp;gt;=0.5)*0.5+int(x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2025 16:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955926#M373300</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-13T16:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Trunc by 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955927#M373301</link>
      <description>&lt;P&gt;Very simple.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data numbers;
  input have want ;
  result = int(2*have)/2 ;
  diff = result-want;
datalines;
2.2 2
2.6 2.5
2.9 2.5
3.1 3
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really have character variables instead of numbers then first convert the character string into a number using INPUT().&amp;nbsp; If you want a character result then convert the number to a string using PUT().&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 16:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955927#M373301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-13T16:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trunc by 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955947#M373305</link>
      <description>&lt;P&gt;I think your objective can be resolved via the second argument of the ROUND function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(have,0.5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are starting out with character variable (say with length 5), then&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(input(have,5.),0.5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2025 18:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/955947#M373305</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2025-01-13T18:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trunc by 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/956033#M373341</link>
      <description>&lt;P&gt;&amp;nbsp;Hi guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot for you answers, it helped me a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Filip&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 10:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trunc-by-0-5/m-p/956033#M373341</guid>
      <dc:creator>filippo_kow</dc:creator>
      <dc:date>2025-01-14T10:50:09Z</dc:date>
    </item>
  </channel>
</rss>

