<?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: Looking up a specific value in a SAS dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619737#M19433</link>
    <description>&lt;P&gt;May be a precision issue with the data grid not showing you the full value.&lt;/P&gt;
&lt;P&gt;What happens if you round the variable to an integer value?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  set dad_health_geocoded;
  if round(rowid_dad,1)=7356228;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here how things look like for me using EG8.2&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35594iC70D77B1A3D21AAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2020 03:24:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-01-24T03:24:55Z</dc:date>
    <item>
      <title>Looking up a specific value in a SAS dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619729#M19429</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have been using SAS number of years now. I would not consider myself an expert but I know a lot of basic stuff and the first time since I started using SAS I faced this problem. I imported a .csv file into SAS and saved it as a SAS dataset. I am trying to find a particular value within a numeric field in that dataset and in the menu bar I go to the Data and select "Where" and type in the value I'm looking for (it's a7-digit integer) and I'm getting no row where that field is equal to the value I'm trying to find. Under normal circumstances this would not raise any flag for me thinking that that value should not be in the dataset but I know that value for that field is in the dataset. In fact if I go to the dataset and look for it row by row I can see that value is there. I'm perplexed. Anybody can think of any reason why?&lt;/P&gt;&lt;P&gt;I do the same search with the data function below:&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;set dad_health_geocoded;&lt;/P&gt;&lt;P&gt;if rowid_dad=7356228;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is the log:&lt;/P&gt;&lt;P&gt;There were 114295 observations read from the data set WORK.DAD_HEALTH_GEOCODED.&lt;BR /&gt;NOTE: The data set WORK.TEST1 has 0 observations and 19 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any direction/help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recep&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 01:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619729#M19429</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2020-01-24T01:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up a specific value in a SAS dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619737#M19433</link>
      <description>&lt;P&gt;May be a precision issue with the data grid not showing you the full value.&lt;/P&gt;
&lt;P&gt;What happens if you round the variable to an integer value?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  set dad_health_geocoded;
  if round(rowid_dad,1)=7356228;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here how things look like for me using EG8.2&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35594iC70D77B1A3D21AAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 03:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619737#M19433</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-24T03:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up a specific value in a SAS dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619748#M19440</link>
      <description>&lt;P&gt;Doesn't the GUI tool you are using to look at the data show you the observation number? Let's assume it is observation number 12,345.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  set dad_health_geocoded firstobs=12345 obs=12345;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jan 2020 03:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619748#M19440</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-24T03:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up a specific value in a SAS dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619792#M19448</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122505"&gt;@Recep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to find a particular value within a numeric field in that dataset and in the menu bar I go to the Data and select "Where" and type in the value I'm looking for (it's a7-digit integer) and I'm getting no row (...). In fact if I go to the dataset and look for it row by row I can see that value is there.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122505"&gt;@Recep&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that what &lt;U&gt;you&lt;/U&gt;&amp;nbsp;see are always &lt;STRONG&gt;formatted&lt;/STRONG&gt;&amp;nbsp;numeric values, whereas the &lt;U&gt;computer&lt;/U&gt; "sees" only the &lt;STRONG&gt;internal binary representations&lt;/STRONG&gt; of the numeric values, in particular when it applies WHERE or IF conditions. Unfortunately (for us humans), these two are different &lt;EM&gt;except&lt;/EM&gt;&amp;nbsp;in the rare cases when a format such as &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1b6ugw71lmhnpn1wixijtysezzg.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BINARY64.&lt;/A&gt; or &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n0ueabv26pr2fwn19uxk2f4bf10y.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;HEX16.&lt;/A&gt; is used which reveals the internal binary representation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, one potential issue is that there's a format associated with variable&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;rowid_dad&lt;/FONT&gt;&amp;nbsp;in the dataset, for example 8., which would round the number to an integer if the original value had decimal places (like 7356227.8 or 7356228.4). As you certainly know, you can check this in PROC CONTENTS output. But the formatting could also be due to some &lt;EM&gt;default format&lt;/EM&gt; that is tacitly applied when you "look into" a dataset, be it in the data grid or with PROC PRINT, etc. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;has pointed out, small deviations from the exact integer value could be hidden by the default format. A typical reason for such small deviations are rounding errors from calculations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In fact, under Windows or Unix there are &lt;EM&gt;six&lt;/EM&gt; different numeric values &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; (i.e. internal binary representations) which are displayed in virtually all common numeric formats (e.g. BEST12., BEST16., BEST32., E32., 16.8, 32.24, etc.) as if they were equal to 7356228, but only &lt;EM&gt;one&lt;/EM&gt; of them does satisfy the condition &lt;FONT face="courier new,courier"&gt;x=7356228&lt;/FONT&gt;. It is the third of the six values shown below (highlighted in green).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x hex16.;
b32=put(x, best32.);
b16=put(x, best16.);
b12=put(x, best12.);
e32=put(x, e32.);
w32=put(x, 32.24);
w16=put(x, 16.8);
bin=put(x, binary64.);
hex=put(x, hex16.);
cards;
415C0FD0FFFFFFFE
415C0FD0FFFFFFFF
415C0FD100000000
415C0FD100000001
415C0FD100000002
415C0FD100000003
;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;PRE&gt;Obs      x         b32        b16        b12                    e32

 1    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06
 2    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06
&lt;FONT color="#008000"&gt;&lt;STRONG&gt; 3    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06&lt;/STRONG&gt;&lt;/FONT&gt;
 4    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06
 5    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06
 6    7356228    7356228    7356228    7356228    7.3562280000000000000000000E+06

Obs                 w32                         w16

 1    7356228.000000000000000000000000    7356228.00000000
 2    7356228.000000000000000000000000    7356228.00000000
&lt;STRONG&gt;&lt;FONT color="#008000"&gt; 3    7356228.000000000000000000000000    7356228.00000000&lt;/FONT&gt;&lt;/STRONG&gt;
 4    7356228.000000000000000000000000    7356228.00000000
 5    7356228.000000000000000000000000    7356228.00000000
 6    7356228.000000000000000000000000    7356228.00000000

Obs                                 bin                                         hex

 1    0100000101011100000011111101000011111111111111111111111111111110    415C0FD0FFFFFFFE
 2    0100000101011100000011111101000011111111111111111111111111111111    415C0FD0FFFFFFFF
 &lt;STRONG&gt;&lt;FONT color="#008000"&gt;3    0100000101011100000011111101000100000000000000000000000000000000    415C0FD100000000&lt;/FONT&gt;&lt;/STRONG&gt;
 4    0100000101011100000011111101000100000000000000000000000000000001    415C0FD100000001
 5    0100000101011100000011111101000100000000000000000000000000000010    415C0FD100000002
 6    0100000101011100000011111101000100000000000000000000000000000011    415C0FD100000003&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To find out the &lt;EM&gt;true&lt;/EM&gt; value of&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;rowid_dad&lt;/FONT&gt;, display its internal representation using the HEX16. or BINARY64. format. Use the observation number (as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has mentioned) or other variables to identify the record containing the value in question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have(firstobs=12345 obs=12345);
format rowid_dad hex16.;
var rowid_dad;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Compare the result to the "standard representation" of the integer, i.e.&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;415C0FD100000000&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;(in HEX16. format) in the case of 7356228, and you will see the difference. Other formats, e.g. BEST16. (or even the default format obtained with &lt;FONT face="courier new,courier"&gt;format rowid_dad;&lt;/FONT&gt;&amp;nbsp;in the PROC PRINT step), will be useful if there's a "larger" deviation from 7356228 like 7356228.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you know the true value, you can adapt the WHERE or IF condition accordingly. The ROUND function (suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;) is an important tool for this purpose in many cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 11:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619792#M19448</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-01-24T11:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up a specific value in a SAS dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619906#M19468</link>
      <description>&lt;P&gt;Thanks a lot for all the responses! I'll look into them today and post what I find based on the recommendations. Please follow it.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 18:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-up-a-specific-value-in-a-SAS-dataset/m-p/619906#M19468</guid>
      <dc:creator>Recep</dc:creator>
      <dc:date>2020-01-24T18:43:51Z</dc:date>
    </item>
  </channel>
</rss>

