<?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 cross reference ID number with a table containing valid ID numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805442#M317287</link>
    <description>&lt;P&gt;Best approach with modern SAS tools, requires no sorting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  match
  discrepancy
;
set check;
if _n_ = 1
then do;
  declare hash v (dataset:"valid");
  v.definekey("id");
  v.definedone();
end;
if v.check() = 0
then output match;
else output discrepancy;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested; for tested code, provide usable example data in data steps with datalines.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 07:17:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-04-01T07:17:03Z</dc:date>
    <item>
      <title>How to cross reference ID number with a table containing valid ID numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805412#M317266</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I would like to check if the ID numbers listed in one dataset are valid given a column of valid ID values in another dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Check:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ID Name Age&lt;/P&gt;&lt;P&gt;A5 Liz 25&lt;/P&gt;&lt;P&gt;3B Bob 31&lt;/P&gt;&lt;P&gt;55 Bill 33&lt;/P&gt;&lt;P&gt;BE Ash 19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Valid: (this is an imported Excel file)&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;A5&lt;/P&gt;&lt;P&gt;BE&lt;/P&gt;&lt;P&gt;18&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired output:&lt;/P&gt;&lt;P&gt;Discrepancies&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ID Name Age&lt;/P&gt;&lt;P&gt;55 Bill 33&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;There is no set format for the ID (could be a string, integer, mixture) etc. Essentially, I want to cross reference each ID in Check with the entire column ID in Valid and keep the row if it is not found within Valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data match discrepancy;&lt;/P&gt;&lt;P&gt;set check;&lt;/P&gt;&lt;P&gt;if ID in valid then output match;&lt;/P&gt;&lt;P&gt;else output discrepancy;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which returns an error that the right hand operator is not an array name or constant value list.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any guidance would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Mar 2022 23:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805412#M317266</guid>
      <dc:creator>meriS</dc:creator>
      <dc:date>2022-03-31T23:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to cross reference ID number with a table containing valid ID numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805415#M317268</link>
      <description>&lt;P&gt;1. Sort both tables by ID, the lookup table with valid IDs using option nodupkey&lt;/P&gt;
&lt;P&gt;2. Data step merge. Something like:&lt;/P&gt;
&lt;PRE&gt;data valid invalid;
  merge have valid_ids(in=in_valid);
  by id;
  if in_valid =1 then output valid;
  else if in_valid=0 then output invalid;
run; 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 23:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805415#M317268</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-03-31T23:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to cross reference ID number with a table containing valid ID numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805442#M317287</link>
      <description>&lt;P&gt;Best approach with modern SAS tools, requires no sorting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data
  match
  discrepancy
;
set check;
if _n_ = 1
then do;
  declare hash v (dataset:"valid");
  v.definekey("id");
  v.definedone();
end;
if v.check() = 0
then output match;
else output discrepancy;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested; for tested code, provide usable example data in data steps with datalines.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-cross-reference-ID-number-with-a-table-containing-valid/m-p/805442#M317287</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-01T07:17:03Z</dc:date>
    </item>
  </channel>
</rss>

