<?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: Filter data based on first, middle and last names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810409#M319583</link>
    <description>Japelin, your code works for me. Thanks for sharing the logic.</description>
    <pubDate>Thu, 28 Apr 2022 16:19:35 GMT</pubDate>
    <dc:creator>buddha_d</dc:creator>
    <dc:date>2022-04-28T16:19:35Z</dc:date>
    <item>
      <title>Filter data based on first, middle and last names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810273#M319527</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table WORK.have( bufsize=65536 )
  (
   acct_nbr char(150) format=$150. informat=$150. label='acct_number',
   Acct_NAME char(150),
   cust_name1 char(150),
   cust_name2 char(150),
   first_name char(150),
   middle_name char(150),
   last_name char(150)
  );

insert into WORK.have
values('54321', 'BUTSCH FAITH', 'PETER R BUTSCH', '', 'PETER', 'RAY', 'BUTSCH' )
values('54321', 'BUTSCH PETER', 'FAITH F BUTSCH', '', 'FAITH', 'FINN', 'BUTSCH' )
values('54321', 'FAITH BUTSCH', 'PETER R BUTSCH', '', 'PETER', 'RIVER', 'BUTSCH' )
values('54321', 'FINN BUTSCH', 'PETER R BUTSCH', '', 'PETER', 'RIVER', 'BUTSCH' )
values('54321', 'BUTSCH RAY', 'PETER R BUTSCH', '', 'PETER', 'RIVER', 'BUTSCH' )
values('54321', 'RAY PETER', 'PETER R BUTSCH', '', 'PETER', 'RIVER', 'BUTSCH' )
values('54321', 'MARY JAY RICHARDSON', 'FAITH F BUTSCH', '', 'FAITH', 'FINN', 'BUTSCH' )
values('12345', 'DONALD W WICK', 'NANCY DIANE WICK','', 'NANCY', 'DIANE','WICK')
values('12345', 'DONALD WICK', 'NANCY DIANE WICK','', 'NANCY', 'DIANE', 'WICK')
values('12345', 'NANCY WICK',	'DONALD W WICK','','DONALD','W','WICK')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the above data. This is the sample data and I need to filter data based on acct_name field with first_name, middle_name and last_name fields. You could use other fields as well. But, what I need to see is the record where acct_name is totally different from any first_name, middle_name and last_name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output should look like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;acct_nbr Acct_NAME cust_name1 cust_name2 first_name middle_name last_name&lt;BR /&gt;54321 MARY JAY RICHARDSON FAITH F BUTSCH FAITH FINN BUTSCH&lt;BR /&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 20:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810273#M319527</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2022-04-27T20:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on first, middle and last names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810292#M319539</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  array names{5} cust_name1 cust_name2 first_name middle_name last_name;
  do i=1 to dim(names);
    index=find(Acct_NAME,names{i},'IT');
    if index&amp;gt;0 then delete;
  end;
  drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Apr 2022 01:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810292#M319539</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-04-28T01:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on first, middle and last names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810299#M319543</link>
      <description>&lt;P&gt;You could try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as select * from have
  where not indexw(Acct_NAME,first_name) 
    and not indexw(Acct_NAME,middle_name) 
    and not indexw(Acct_NAME,last_name) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The solution is similar to the datastep shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;, but it does not check CUST_NAME1-2, as you did not mention those, and it checks if the first/middle/last name occurs as a word in ACCT_NAME (assuming that you want records like 'WALTER ROBINSON' vs. 'ROBIN', 'T', 'HENDRICKS', - ROBIN should not match ROBINSON) by using the INDEXW function.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 04:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810299#M319543</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-28T04:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on first, middle and last names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810409#M319583</link>
      <description>Japelin, your code works for me. Thanks for sharing the logic.</description>
      <pubDate>Thu, 28 Apr 2022 16:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810409#M319583</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2022-04-28T16:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on first, middle and last names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810410#M319584</link>
      <description>S_lassen, your logic works for me as well. Thank you so much for sharing.</description>
      <pubDate>Thu, 28 Apr 2022 16:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-data-based-on-first-middle-and-last-names/m-p/810410#M319584</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2022-04-28T16:20:22Z</dc:date>
    </item>
  </channel>
</rss>

