<?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 Odd function in SAS in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42394#M5014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's no ODD function that I know of, but this approach may work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lower_odd = floor(original_number);&lt;/P&gt;&lt;P&gt;if mod(lower_odd,2) = 0 then lower_odd = lower_odd - 1;&lt;/P&gt;&lt;P&gt;if original_number - lower_odd &amp;lt; 1 then closest_odd = lower_odd;&lt;/P&gt;&lt;P&gt;else closest_odd = lower_odd + 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use base SAS, hardly ever in EG.&amp;nbsp; So I don't know if you'll need to adapt this or not.&amp;nbsp; And you'll have to set up rules for ties.&amp;nbsp; What if the original number is 4?&amp;nbsp; What if it is -4?&amp;nbsp; All of that can be coded though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jan 2012 19:21:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-01-31T19:21:46Z</dc:date>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42392#M5012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there an equivalent function in enterprise guide to the odd function in excel? or a similar formula to round a number to nearest odd integer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿&lt;/P&gt;﻿﻿﻿﻿&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 18:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42392#M5012</guid>
      <dc:creator>PJorge</dc:creator>
      <dc:date>2012-01-31T18:35:22Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42393#M5013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are on 9.2, or newer, there are a number of excel functions that are now availble in the FCMP library.&amp;nbsp; Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options cmplib = sashelp.slkwxl;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=odd_slk(x);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, if you are not on 9.2 or newer, you can simply submit the code that the function uses:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = int(x) + sign(mod(x,int(x)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(x);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42393#M5013</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T19:16:55Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42394#M5014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's no ODD function that I know of, but this approach may work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lower_odd = floor(original_number);&lt;/P&gt;&lt;P&gt;if mod(lower_odd,2) = 0 then lower_odd = lower_odd - 1;&lt;/P&gt;&lt;P&gt;if original_number - lower_odd &amp;lt; 1 then closest_odd = lower_odd;&lt;/P&gt;&lt;P&gt;else closest_odd = lower_odd + 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use base SAS, hardly ever in EG.&amp;nbsp; So I don't know if you'll need to adapt this or not.&amp;nbsp; And you'll have to set up rules for ties.&amp;nbsp; What if the original number is 4?&amp;nbsp; What if it is -4?&amp;nbsp; All of that can be coded though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42394#M5014</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-01-31T19:21:46Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42395#M5015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for let us know this new feature of SAS 9.2. I know nothing of Excel ODD() function. However, the function you have introduced&amp;nbsp; does not round to nearest odd number like OP suggested,&amp;nbsp; instead, it only ceiling up to the next odd number. Please see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options cmplib = sashelp.slkwxl;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;do i=1 by 0.25 to 10;&lt;/P&gt;&lt;P&gt;j=ifn(mod(floor(i),2)=0,floor(i)+1,floor(i));&lt;/P&gt;&lt;P&gt;k=odd_slk(i);&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42395#M5015</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-01-31T19:33:48Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42396#M5016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haikuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Agreed!&amp;nbsp; The function is definitely lacking a step.&amp;nbsp; I think that the following matches Excel for all numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=ifn(x eq 0,1,round(x));&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = int(y) + sign(mod(y,int(y)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42396#M5016</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T19:49:39Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42397#M5017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you still have to guard against some values.&amp;nbsp; If you start with x=0.25, for example, the MOD function will attempt division by zero.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42397#M5017</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-01-31T19:55:49Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42398#M5018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How about nesting two round functions.&amp;nbsp; Let me know if the following misses any cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=ifn(x eq 0,1,round(round(x,.5)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = int(y) + sign(mod(y,int(y)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 20:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42398#M5018</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T20:15:54Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42399#M5019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The more I look, the more I question.&amp;nbsp; These statements would handle small values:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if x=0 then y=1;&lt;/P&gt;&lt;P&gt;else if abs(x) &amp;lt; 1 then y = sign(x);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But for other cases, if y has already been rounded to an integer, wouldn't this expression always be equal to 0:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sign(mod(y,int(y)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is still some work to be done here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42399#M5019</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-01-31T21:00:22Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42400#M5020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested it with the following data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;-9&lt;/P&gt;&lt;P&gt;-8&lt;/P&gt;&lt;P&gt;-7&lt;/P&gt;&lt;P&gt;-6&lt;/P&gt;&lt;P&gt;-5&lt;/P&gt;&lt;P&gt;-4&lt;/P&gt;&lt;P&gt;-3&lt;/P&gt;&lt;P&gt;-2&lt;/P&gt;&lt;P&gt;-1.5&lt;/P&gt;&lt;P&gt;-1&lt;/P&gt;&lt;P&gt;-.5&lt;/P&gt;&lt;P&gt;-.25&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;.25&lt;/P&gt;&lt;P&gt;.5&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1.5&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=ifn(x eq 0,1,round(round(x,.5)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = int(y) + sign(mod(y,int(y)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which resulted as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; -9.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; -8.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; -7.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; -6.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; -5.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; -4.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; -3.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; -2.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp; -1.50&amp;nbsp;&amp;nbsp;&amp;nbsp; -3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; -1.00&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 11&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.50&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.25&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.50&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp; 21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp; 22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;&lt;P&gt;&amp;nbsp; 23&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;&lt;P&gt;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/P&gt;&lt;P&gt;&amp;nbsp; 25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which I believe are the same values one would obtain from the Excel odd function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42400#M5020</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T21:12:08Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42401#M5021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far, so good.&amp;nbsp; Please try two more tests.&amp;nbsp; First, use the same program but try adding 0.1 as an incoming value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then run all the data (including 0.1 plus all the other values) through a similar program, but eliminate the middle statement entirely:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;y = int(y) + ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42401#M5021</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-01-31T21:26:26Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42402#M5022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding (and anyone else keeping up with this),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definitely still need(ed) some more work.&amp;nbsp; Removing the middle statement didn't correct matters, but I expanded the test file and added a nested set of ifn functions.&amp;nbsp; Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input x;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format x 12.6;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;-9&lt;/P&gt;&lt;P&gt;-8&lt;/P&gt;&lt;P&gt;-7&lt;/P&gt;&lt;P&gt;-6&lt;/P&gt;&lt;P&gt;-5&lt;/P&gt;&lt;P&gt;-4.000001&lt;/P&gt;&lt;P&gt;-4&lt;/P&gt;&lt;P&gt;-3&lt;/P&gt;&lt;P&gt;-2&lt;/P&gt;&lt;P&gt;-1.5&lt;/P&gt;&lt;P&gt;-1&lt;/P&gt;&lt;P&gt;-.5&lt;/P&gt;&lt;P&gt;-.25&lt;/P&gt;&lt;P&gt;-.1&lt;/P&gt;&lt;P&gt;-.000001&lt;/P&gt;&lt;P&gt;0&lt;/P&gt;&lt;P&gt;.000001&lt;/P&gt;&lt;P&gt;.1&lt;/P&gt;&lt;P&gt;.25&lt;/P&gt;&lt;P&gt;.5&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;1.5&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;4.000001&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=ifn(0&amp;lt;=x&amp;lt;=.5,1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ifn(-.5&amp;lt;x&amp;lt;0,-1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; round(round(x,.5))));&lt;/P&gt;&lt;P&gt;&amp;nbsp; y = int(y) + sign(mod(y,int(y)));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42402#M5022</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T21:47:12Z</dc:date>
    </item>
    <item>
      <title>Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42403#M5023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definitely on the right track here.&amp;nbsp; I suggested removing that middle statement because it looks like it's not doing anything.&amp;nbsp; It always leaves Y unchanged.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The cases to handle are dwindling, but it looks like there is still one consideration.&amp;nbsp; I think the double-rounding will cause a problem for 1.3.&amp;nbsp; It looks like you'll get 3 instead of 1 as the result.&amp;nbsp; Going back to the single rounding will take care of that.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To my tired eyes, that should do it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 21:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42403#M5023</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-01-31T21:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42404#M5024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This matches the output from Excel for the odd function using all Art's examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿﻿&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: navy; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;proc&lt;/SPAN&gt;&lt;SPAN style="color: navy; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;fcmp&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; function excel_odd(n);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp; return(ifn(n ge &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;,ceil(n)+(mod(ceil(n),&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;)=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;),floor(n)-(mod(floor(n),&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;)=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; endsub;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; array x[&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;31&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;](-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;9&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;7&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;5&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;4.00001&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1.5&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.5&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.25&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; -&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.1&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;.00001&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;.00001&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;.1&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;.25&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;.5&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;1.5&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;2&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;3&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;4&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;4.00001&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;5&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;6&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;7&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;8&lt;/SPAN&gt;&lt;SPAN style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;9&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; do i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;to dim(x);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp; excel_odd=excel_odd(x&lt;I&gt;);&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;&amp;nbsp; put excel_odd=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-family: 'Courier New';"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 22:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42404#M5024</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-01-31T22:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42405#M5025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No and Yes!&amp;nbsp; According to the Excel function, 0 and anything greater than an odd integer should be rounded up to the next odd integer (thus 1.3 should result in 3), and any negative number that is not an odd integer should result in the next lower odd integer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, the middle line is no longer needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus the "final" code should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; y=ifn(0&amp;lt;=x&amp;lt;=.5,1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ifn(-.5&amp;lt;x&amp;lt;0,-1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; round(round(x,.5))));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ( mod(y,2) eq 0 ) then y + sign(y);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't tested FriedEgg's fcmp solution yet.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 22:34:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42405#M5025</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-31T22:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42406#M5026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand correctly I think FLOOR for negative and CEIL for positive should be used instead of ROUND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;(sign(val));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c&amp;nbsp;&amp;nbsp; = ceilz(val);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; odd = not modz(c,&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r&amp;nbsp;&amp;nbsp; = c + odd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;(-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c&amp;nbsp;&amp;nbsp; = floorz(val);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; odd = not modz(c,&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r&amp;nbsp;&amp;nbsp; = c - odd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;when&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;) r=1&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;otherwise&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 11:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42406#M5026</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-02-01T11:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42407#M5027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DataNull, I totally agree.&amp;nbsp; Using the round function incorrectly assigned small fraction odd numbers (e.g., 5.00001), while your suggested code handles it quite nicely.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 13:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42407#M5027</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-01T13:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42408#M5028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You guys beat me to it.&amp;nbsp; Here's the one-line version:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;y = ifn( x &amp;gt;= 0, ceil(x) + (mod(ceil(x),2)=0), floor(x) - (mod(floor(x),2)=0));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nothing like understanding the question when you try to work on an answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 14:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42408#M5028</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-02-01T14:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42409#M5029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Astounding,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In all fairness, FriedEgg's and DataNull's proposed solutions also appear to work perfectly.&amp;nbsp; However, I *really* like your one liner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case I've never mentioned it here, I'm a psychologist/director, not a programmer.&amp;nbsp; The role I think I play here, and used to do on SAS-L, is to help refine interesting looking questions and, at the same time, motivate others to show the rest of us how it should/can be done.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2012 14:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42409#M5029</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-01T14:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42410#M5030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just want to let you know that I got the results I wanted. All of your input were amazing and really helped me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS- I used the one line formula suggested by Astounding&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 11:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42410#M5030</guid>
      <dc:creator>PJorge</dc:creator>
      <dc:date>2012-02-02T11:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Odd function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42411#M5031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then mark his/her answer as being correct!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Feb 2012 13:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Odd-function-in-SAS/m-p/42411#M5031</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-02T13:24:33Z</dc:date>
    </item>
  </channel>
</rss>

