<?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: Variable appears to have numbers to right of decimal in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924720#M363973</link>
    <description>&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something to remember when dealing with SAS data is variables always have a format assigned. The format may round or truncated displayed characters.&lt;/P&gt;
&lt;P&gt;So if I execute this code:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x= 7.0000000000056789;
run;&lt;/PRE&gt;
&lt;P&gt;and open the table viewer I see a value of 7. Why? Because the default format that was assigned is BEST12. since I did not explicitly assign one. The digits other that 0 are past what 12 characters would display so the best format rounds to the integer.&lt;/P&gt;
&lt;P&gt;However if assign a format such as F32.20 (32 characters allowing for 20 decimal places) then I see 7.00000000000568000000 (more zeroes to the right to make up 20).&lt;/P&gt;
&lt;P&gt;So change your format to display more decimal places. I would start with 16 and not use one of the BEST. If you have values in the 14/15th decimal place they may not be accurate due to precision of storage so what you see may not be what the source has though likely something.&lt;/P&gt;
&lt;P&gt;You may have to point to the data file actually read. Since this seems like a surprise I might guess this is from connecting to an external data source and not reading a text file. So properties of the source may also be masking such extraneous digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 15:22:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-04-17T15:22:25Z</dc:date>
    <item>
      <title>Variable appears to have numbers to right of decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924712#M363969</link>
      <description>&lt;P&gt;I have a dataset with codes that look like this:&lt;/P&gt;
&lt;DIV style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;DIV id="IDX" style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="Data Set WORK.DS"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;rcode&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to filter on code 7, it doesn't return any results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select * from ds
where rcode in (1,2,3,4,5,6,7,8,9)
;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns this (note that 7 is missing):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;DIV id="IDX" style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="Query Results"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;rcode&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like maybe the 7 code has digits to the right of the decimal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds2;&lt;BR /&gt;set ds;&lt;BR /&gt;test = put (rcode,bestd32.);&lt;BR /&gt;run;&lt;BR /&gt;proc print data=ds2 NOOBS; run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results of the above code:&lt;/P&gt;
&lt;DIV style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;DIV id="IDX" style="padding-top: 1px; padding-bottom: 8px;"&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="Data Set WORK.DS2"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;rcode&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;test&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;TD class="data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;TD class="data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;TD class="data"&gt;7.0000000000000000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;TD class="data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;TD class="data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;If the code doesn't equal 7, then what is it's value? I'm not looking for workarounds but rather a way to see the true value (maybe it's 7.0000000000001, for example). Once I know what the true value is, I can have the person that maintains this data correct it. Right now they are saying it equals 7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've also tried viewing the dataset in EG but it just looks like a 7.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-04-17_10-59.png" style="width: 419px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95631iD3CB4D1AB6A0803B/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-04-17_10-59.png" alt="2024-04-17_10-59.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Filtering on 7 produces no results (not an issue with any of the other numbers):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-04-17_10-58.png" style="width: 355px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95630iC8556D47B12D4D2F/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-04-17_10-58.png" alt="2024-04-17_10-58.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924712#M363969</guid>
      <dc:creator>tedway</dc:creator>
      <dc:date>2024-04-17T15:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Variable appears to have numbers to right of decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924720#M363973</link>
      <description>&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;Format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something to remember when dealing with SAS data is variables always have a format assigned. The format may round or truncated displayed characters.&lt;/P&gt;
&lt;P&gt;So if I execute this code:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x= 7.0000000000056789;
run;&lt;/PRE&gt;
&lt;P&gt;and open the table viewer I see a value of 7. Why? Because the default format that was assigned is BEST12. since I did not explicitly assign one. The digits other that 0 are past what 12 characters would display so the best format rounds to the integer.&lt;/P&gt;
&lt;P&gt;However if assign a format such as F32.20 (32 characters allowing for 20 decimal places) then I see 7.00000000000568000000 (more zeroes to the right to make up 20).&lt;/P&gt;
&lt;P&gt;So change your format to display more decimal places. I would start with 16 and not use one of the BEST. If you have values in the 14/15th decimal place they may not be accurate due to precision of storage so what you see may not be what the source has though likely something.&lt;/P&gt;
&lt;P&gt;You may have to point to the data file actually read. Since this seems like a surprise I might guess this is from connecting to an external data source and not reading a text file. So properties of the source may also be masking such extraneous digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924720#M363973</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-17T15:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Variable appears to have numbers to right of decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924722#M363975</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140633"&gt;@tedway&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few numeric formats which reveal the actual (binary!) content of a numeric variable. These include BINARY64. (binary format, i.e., sequence of 0s and 1s), HEX16. (same, but in hexadecimal digits) and RB8. (character string, more difficult to use). But I think you are more interested in the &lt;EM&gt;decimal&lt;/EM&gt; value. In this case you create a new variable, say, DIFF7, defined as&lt;/P&gt;
&lt;PRE&gt;diff7=rcode-7&lt;/PRE&gt;
&lt;P&gt;In the observation where you see &lt;FONT face="courier new,courier"&gt;rcode=7&lt;/FONT&gt; it will be something like &lt;FONT face="courier new,courier"&gt;8.881784E-16&lt;/FONT&gt; or maybe a negative value of similar order of magnitude. Then you know that &lt;FONT face="courier new,courier"&gt;rcode&lt;/FONT&gt; really contains 7 plus that tiny (positive or negative) value.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924722#M363975</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-17T15:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Variable appears to have numbers to right of decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924724#M363977</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Something to remember when dealing with SAS data is variables always have a format assigned. The format may round or truncated displayed characters.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;: Exactly. But sadly this is true for F32.20, BEST32., E32., etc. as well. So there are cases where these (non-binary) formats still hide those tiny differences. Then it may help to set&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options decimalconv=stdieee;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but personally I prefer the HEX16. format and use the &lt;A href="https://communities.sas.com/t5/SAS-Programming/Converting-a-19-length-number-to-hex-and-then-to-a-string/m-p/654626/highlight/true#M196566" target="_blank" rel="noopener"&gt;BASECONVFP function&lt;/A&gt; if an exact decimal value is of interest.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-appears-to-have-numbers-to-right-of-decimal/m-p/924724#M363977</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-17T15:56:48Z</dc:date>
    </item>
  </channel>
</rss>

