<?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: Records by condition exist in proc freq, but subset by condition return 0 records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700608#M214420</link>
    <description>&lt;P&gt;Numeric precision, some decimal values don't always store cleanly in a binary form could be an issue and possibly compounded by the CEDA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using either&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if round(v_h,0.1) = 1.4;&lt;/P&gt;
&lt;P&gt;or an equivalent Where.&lt;/P&gt;
&lt;P&gt;And sometimes you may want to use something like: If put(var, formatname.) = "formatted value" as some formats can do some pretty interesting things to specific values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: you do need to consider Formated value versus actual sometimes, especially when looking at Proc Freq values to select things.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;data example;
   x=1.423;
   format x 4.1;
run;
proc freq data=example;
run;&lt;/PRE&gt;
&lt;P&gt;The output shows "1.4" in the Proc Freq output but the value is NOT 1.4.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Nov 2020 20:55:31 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-11-20T20:55:31Z</dc:date>
    <item>
      <title>Records by condition exist in proc freq, but subset by condition return 0 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700602#M214417</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to subset a dataset by using where clause on a variable, v_h, with the following format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;v_h :&amp;nbsp; type = Num, Len = 8, Format = 4.1, Informat = 4.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using proc freq on v_h, there are records of v_h = 1.4, but when using where clause to filter the dataset by v_h = 1.4, there are 0 records&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*returned 0 records*/ &lt;BR /&gt;data test;
 set have(where=(v_h=1.4));
run;

data test;
 set have;
   if v_h = 1.4;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also received a message :&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;"NOTE: Data file have.DATA is in a format that is native to another host, or the file encoding&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;does not match the session encoding. Cross Environment Data Access will be used, which might require&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;additional CPU resources and might reduce performance."&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="3"&gt;Could anyone help me to figure out what went wrong?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 20:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700602#M214417</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2020-11-20T20:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Records by condition exist in proc freq, but subset by condition return 0 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700608#M214420</link>
      <description>&lt;P&gt;Numeric precision, some decimal values don't always store cleanly in a binary form could be an issue and possibly compounded by the CEDA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using either&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if round(v_h,0.1) = 1.4;&lt;/P&gt;
&lt;P&gt;or an equivalent Where.&lt;/P&gt;
&lt;P&gt;And sometimes you may want to use something like: If put(var, formatname.) = "formatted value" as some formats can do some pretty interesting things to specific values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: you do need to consider Formated value versus actual sometimes, especially when looking at Proc Freq values to select things.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;data example;
   x=1.423;
   format x 4.1;
run;
proc freq data=example;
run;&lt;/PRE&gt;
&lt;P&gt;The output shows "1.4" in the Proc Freq output but the value is NOT 1.4.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 20:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700608#M214420</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-20T20:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Records by condition exist in proc freq, but subset by condition return 0 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700628#M214430</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to add: Even &lt;EM&gt;without&lt;/EM&gt; an explicit format (such as 4.1 in your case) PROC FREQ would display &lt;EM&gt;many&lt;/EM&gt; different numeric values as "&lt;FONT face="courier new,courier"&gt;1.4&lt;/FONT&gt;" due to rounding:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
do i=1 to 450362;
  v_h=input('3FF66666666'||put(i+194248,hex5.), hex16.);
  output;
end;
run;

proc freq data=test;
tables v_h;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                         Cumulative    Cumulative
         v_h    Frequency     Percent     Frequency      Percent
-----------------------------------------------------------------
1.3999999999           1        0.00             1         0.00
         1.4      450360      100.00        450361       100.00
1.4000000001           1        0.00        450362       100.00&lt;/PRE&gt;
&lt;P&gt;So,&amp;nbsp;&lt;STRONG&gt;450360&lt;/STRONG&gt; different values (under Windows) are counted as &lt;FONT face="courier new,courier"&gt;1.4&lt;/FONT&gt;, only &lt;EM&gt;one&lt;/EM&gt; of which satisfies the condition &lt;FONT face="courier new,courier"&gt;v_h=1.4&lt;/FONT&gt;. [Edit: Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270201"&gt;@Watts&lt;/a&gt;'s explanation we could have calculated that number of different values in advance: The real numbers whose values rounded to 10 decimals equal 1.4 form an interval of length 1E-10. The least significant bit in the internal binary floating-point representation of these numbers has a place value of 2**-52. And finally&amp;nbsp;&lt;FONT face="courier new,courier"&gt;round(1E-10/2**-52)=450360&lt;/FONT&gt;.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of those "different" values can easily result from computations involving decimal fractions:&lt;/P&gt;
&lt;PRE&gt;601  data bad;
602  v_h=0.14*10;
603  put v_h=;
604  if v_h=1.4;
605  run;

v_h=1.4
&lt;FONT color="#0000FF"&gt;NOTE: The data set WORK.BAD has 0 observations and 1 variables.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Again, zero observations, in spite of the &lt;EM&gt;implicitly&lt;/EM&gt; rounded value 1.4 from the PUT statement. A slight adjustment like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if round(v_h, 1e-10)=1.4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would have avoided the error.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 15:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700628#M214430</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-11-23T15:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Records by condition exist in proc freq, but subset by condition return 0 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700697#M214475</link>
      <description>&lt;P&gt;Yes, PROC FREQ groups observations into levels by using the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;locale=en" target="_self"&gt;formatted values&lt;/A&gt;. By default (if a format isn't specified), the format of a numeric variable is BEST12.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 15:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700697#M214475</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-11-21T15:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Records by condition exist in proc freq, but subset by condition return 0 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700902#M214556</link>
      <description>thank you</description>
      <pubDate>Mon, 23 Nov 2020 13:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Records-by-condition-exist-in-proc-freq-but-subset-by-condition/m-p/700902#M214556</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2020-11-23T13:37:45Z</dc:date>
    </item>
  </channel>
</rss>

