<?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: How to Provide Correct Result on Where Statement By Using Formatted Value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267753#M52950</link>
    <description>Thanks a lot, very useful information. Did you learn these information from any course books or I don't know, somewhere?

Thanks</description>
    <pubDate>Mon, 02 May 2016 23:04:41 GMT</pubDate>
    <dc:creator>turcay</dc:creator>
    <dc:date>2016-05-02T23:04:41Z</dc:date>
    <item>
      <title>How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267724#M52937</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nowadays, I’m working on customer place. I don’t know the reason but the default data comes being formatted . Think that there are&amp;nbsp; 18 million rows and I need to use formatted values on Where statement but when I use formatted value on Where statement it brings missing value. I can be two purposes. 1 -&amp;gt; learn how to use formatted value on Where statment to bring right result or 2 -&amp;gt; remove the format of table to use default values on Where statement. Thinking you can help me, I prepared a sample data as below. If you can help me I would be so pleased.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length ID $ 10 Var1 8;
Infile Datalines Missover;
Input ID Var1;
Format Var1 7.1;
Datalines;
1 12.12456
2 12.26544
3 1.45567
;
Run;
Data Want;
Set Have;
/*Format Var1 7.1;*/
Where Var1=12.1;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 20:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267724#M52937</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2016-05-02T20:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267727#M52939</link>
      <description>&lt;P&gt;Computers have issue storing numbers, because of binary. Google numerical precision SAS to see why.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To overcome this round your values before your comparison:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where round(var1, 0.1)  = 12.1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;EDIT: To clarify - this has nothing to do with formats, it's how computers treats numbers. You'd have the same issue in Excel. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 21:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267727#M52939</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-02T21:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267731#M52940</link>
      <description>&lt;P&gt;... or compare formatted strings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where put(var1, 7.1) = "12.1";&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 21:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267731#M52940</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-02T21:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267741#M52944</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48505"&gt;@turcay﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More generally: By default, WHERE and IF conditions work with &lt;EM&gt;internal&lt;/EM&gt; (i.e. unformatted) values. To use &lt;EM&gt;formatted&lt;/EM&gt; values in a condition, you can use the PUT function, as mentioned by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;. (The VVALUE function is an alternative, but not in WHERE conditions.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the case of conditions involving numeric variables with floating-point values (like in your example) it is highly recommended to use formatted values (with an appropriate format) or the ROUND function (with an appropriate rounding unit), as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;suggested, because in many cases you don't know the exact (!) internal value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(var1, 7.1)='   12.1';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note the three leading blanks. These are required because of the length (7) of format 7.1, unless you apply additional character functions such as LEFT, COMPRESS or STRIP to obtain a left-justified value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, the selection criterion should be well considered. Depending on the input data, the criteria&amp;nbsp;&lt;FONT face="courier new,courier"&gt;round(var1, 0.1)=12.1&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;round(var1, 0.01)=12.1&lt;/FONT&gt; could yield very different results.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 21:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267741#M52944</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-02T21:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267743#M52945</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all of you and for detailed information big thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;. I was little bit confused. Now, I understand better. Just a short question, do three leading blanks are fixed&amp;nbsp;for formats?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 22:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267743#M52945</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2016-05-02T22:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267745#M52947</link>
      <description>&lt;P&gt;It is simpler to override the default alignment with an alignment specification in the PUT function than to add leading blanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where put(var1, 7.1 -L) = "12.1";&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 22:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267745#M52947</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-02T22:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267746#M52948</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/48505"&gt;@turcay&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Just a short question, do three leading blanks are fixed&amp;nbsp;for formats?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, they are not. In that&amp;nbsp;example exactly three were necessary, because the value '12.1' itself is 4 characters long, the format 7.1 has length 7 (more generally: format &lt;EM&gt;w&lt;/EM&gt;.&lt;EM&gt;d&lt;/EM&gt; has length &lt;EM&gt;w&lt;/EM&gt;), it produces right-justified values and 7 - 4 = 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid difficulties with incorrect numbers of leading blanks, you can apply character functions or use the -L format modifier (as PG suggested). For floating-point&amp;nbsp;numbers&amp;nbsp;I mostly use the ROUND function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 22:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267746#M52948</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-02T22:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267753#M52950</link>
      <description>Thanks a lot, very useful information. Did you learn these information from any course books or I don't know, somewhere?

Thanks</description>
      <pubDate>Mon, 02 May 2016 23:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267753#M52950</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2016-05-02T23:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Provide Correct Result on Where Statement By Using Formatted Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267756#M52951</link>
      <description>&lt;P&gt;I learned the basics of SAS programming primarily from the printed SAS 6 documentation (and the built-in help files of SAS 6.12) in my first job and by doing that job, which was very SAS centric.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 23:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Provide-Correct-Result-on-Where-Statement-By-Using/m-p/267756#M52951</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-02T23:56:34Z</dc:date>
    </item>
  </channel>
</rss>

