<?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: select with a where clause in a SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755153#M238253</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you have values = 'GROUP ABC' (in uppercase) in the variable 'VariableName'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe try this case-insensitive comparison:&lt;BR /&gt;(and strip function is removing leading and trailing blanks)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where strip(upcase(tablename.variablename)) = 'GROUP ABC';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jul 2021 23:06:14 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2021-07-19T23:06:14Z</dc:date>
    <item>
      <title>select with a where clause in a SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755150#M238252</link>
      <description>&lt;PRE&gt;Proc sql;

create table mytestTable as
select distinct tablename.variableName
from libName.tablename
where tablename.variablename = upcase('Group ABC');

Quit;&lt;/PRE&gt;
&lt;P&gt;This code doesn't return any values, however, we have values for this variable in the table. Also, log says no error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;blue blue&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 22:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755150#M238252</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-07-19T22:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: select with a where clause in a SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755153#M238253</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you have values = 'GROUP ABC' (in uppercase) in the variable 'VariableName'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe try this case-insensitive comparison:&lt;BR /&gt;(and strip function is removing leading and trailing blanks)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where strip(upcase(tablename.variablename)) = 'GROUP ABC';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 23:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755153#M238253</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-07-19T23:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: select with a where clause in a SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755154#M238254</link>
      <description>&lt;P&gt;You can try to use like operator&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(variable_name) like upcase('%Group ABC%');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jul 2021 23:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755154#M238254</guid>
      <dc:creator>Rydhm</dc:creator>
      <dc:date>2021-07-19T23:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: select with a where clause in a SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755156#M238256</link>
      <description>&lt;P&gt;It is going to come down to actual content of your data in this case assuming you haven't managed to hide a detail by removing actual library, data set and variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Equality with character variables is a very strong requirement. Any&amp;nbsp; minor spelling difference other than trailing blanks will make equality not true. So if your value is "GroupABC" "group ABC" "Group Abc" or harder to spot " Group ABC" they are not equal (lots more variations). For many cases, just to get around minor case differences we will use something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where upcase(variable) = "GROUP ABC" or similar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This returns no records because the variable is not forced to the same case as the comparison&lt;/P&gt;
&lt;PRE&gt;data junk;
   infile datalines missover;
   input var $10.;
datalines;
Group ABC
 Group ABC
group abc
group Abc
;

proc sql;
   create table testtable as
   select distinct var
   from junk
   where var = upcase('Group ABC');

Quit;&lt;/PRE&gt;
&lt;P&gt;This may be more like what you expected:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table testtable2 as
   select distinct var
   from junk
   where upcase(var) = upcase('Group ABC');

Quit;&lt;/PRE&gt;
&lt;P&gt;but still does not find the second value because it has a leading space.&lt;/P&gt;
&lt;P&gt;Which could be addressed with&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table testtable3 as
   select distinct var
   from junk
   where upcase(strip(var)) = upcase('Group ABC');

Quit;&lt;/PRE&gt;
&lt;P&gt;but only 3 in the output because the spelling after striping the leading blank matches the first record.&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;
&lt;P&gt;Equality is evaluated character by character from left to right and as soon as something is not equal SAS returns not equal for the comparison.&lt;/P&gt;
&lt;P&gt;Other things that could be "not equal" is a character in a unicode set that looks like "G" but because the underlying coding is different it is not equal to the "G" you type in programming.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 23:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/select-with-a-where-clause-in-a-SAS/m-p/755156#M238256</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-19T23:18:12Z</dc:date>
    </item>
  </channel>
</rss>

