<?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: What's wrong with my code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411392#M100573</link>
    <description>&lt;P&gt;Character values may appear to match, but not actually match.&amp;nbsp; For example, there can be leading blanks, or even unseen characters such as carriage returns stored within a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take an observation that you think should have matched on both sets of variables, and print the values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put daterange_BZ $hex32.&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;put date_range $hex32.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See whether the values printed in hex format are actually a match or not.&amp;nbsp; Obviously (?), the solution varies, depending on where the problem lies.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2017 23:46:47 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-11-07T23:46:47Z</dc:date>
    <item>
      <title>What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411384#M100568</link>
      <description>&lt;P&gt;Good Afternoon everyone! So, I just realized that the following code doesn't give me perfect results and Im wondering what's going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data All_1;
 set both_ALL ;
 if (daterange_BZ = date_range) and (total_premium_biz = total_premium) then GoodMembers = 'Yes';
 if (daterange_BZ = date_range) and (total_premium_biz ^= total_premium) then SpanMatch = 'Yes';

 run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;daterange_BZ&amp;nbsp;and date_range are both character variables and total_premium_biz/ total_premium are both numeric variables. When I see the results, for some records, goodmembers should be yes (meaning both set of variables match), but the code gives instead&amp;nbsp;spanmatch as yes.&lt;/P&gt;
&lt;P&gt;Any thoughts?&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 22:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411384#M100568</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2017-11-07T22:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411385#M100569</link>
      <description>&lt;P&gt;For comparing numeric variables you may want to round them before comparison. Otherwise, small values can cause issues.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 22:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411385#M100569</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-07T22:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411386#M100570</link>
      <description>&lt;P&gt;Ok thanks. I will check that.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 22:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411386#M100570</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2017-11-07T22:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411391#M100572</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also look if there is a space issue with the character values. If there is a tab space after the string then both will not be same values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data need;&lt;/P&gt;&lt;P&gt;str1="compare ";/* TAB space after string*/&lt;BR /&gt;str2="compare";&lt;BR /&gt;if str1=str2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a space issue, use&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;(strip(&lt;/SPAN&gt;daterange_BZ) &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; strip(date_range&lt;SPAN class="token punctuation"&gt;))&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Nov 2017 23:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411391#M100572</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2017-11-07T23:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411392#M100573</link>
      <description>&lt;P&gt;Character values may appear to match, but not actually match.&amp;nbsp; For example, there can be leading blanks, or even unseen characters such as carriage returns stored within a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take an observation that you think should have matched on both sets of variables, and print the values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put daterange_BZ $hex32.&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;put date_range $hex32.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See whether the values printed in hex format are actually a match or not.&amp;nbsp; Obviously (?), the solution varies, depending on where the problem lies.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 23:46:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411392#M100573</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-07T23:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411568#M100610</link>
      <description>&lt;P&gt;Thanks guys. I believe the problem was simply applying the round function in the comparison. I used the following code now and it seems to give me correct solutions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data All_1;
 set both_ALL ;
 if (daterange_BZ = date_range) and round(total_premium_biz, .1) = round(total_premium, .1) then GoodMembers = 'Yes';
 if (daterange_BZ = date_range) and round(total_premium_biz, .1) ^=  round(total_premium, .1) then SpanMatch = 'Yes';
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2017 16:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411568#M100610</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2017-11-08T16:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: What's wrong with my code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411570#M100611</link>
      <description>&lt;P&gt;You should make the second one an ELSE IF, not an IF. It's better from a logic standpoint and slightly more efficient because if the first statement evaluates as true it will skip the second statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 16:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-s-wrong-with-my-code/m-p/411570#M100611</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-08T16:12:40Z</dc:date>
    </item>
  </channel>
</rss>

