<?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 Macro code for lookup in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604955#M175461</link>
    <description>&lt;P&gt;I've&amp;nbsp; a data as follows in one dataset. Here the mechanism which I want to perform is, CURRENT_ID should be available in RISK_CURVE dataset and INSURANCE_CON. In similar way, GROUP_ID should be available in INSURANCE_CON_GRP and INSURANCE_CON dataset and so on. Here the base dataset is INSURANCE_CON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case if there are some values which are not in base table (INSURANCE_CON)&amp;nbsp;but in reference table (INSURANCE_CON_GRP, RISK_CURVE) &amp;nbsp;then I've to capture that record in the Output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="892"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="556"&gt;&lt;STRONG&gt;Checks&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="336"&gt;&lt;STRONG&gt;TBL_NM&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;CURRENT_ID should be available in RISK_CURVE&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;GROUP_ID should be in INSURANCE_CON_GRP&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;LOCK_ID should be available in RISK_CURVE&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output which I'm looking for,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="292"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="292"&gt;&lt;STRONG&gt;Fault_record_in_reference_table&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,M,Joseph,234&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11,F,Nakma,236&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although this mechanism sounds like a look up, challenge which I have is writing the&amp;nbsp;this validation &amp;nbsp;checks in macro as I've to insert this code in other macro code. Would be grateful if it can be accomplished&amp;nbsp;with minimal code.&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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Nov 2019 12:02:58 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2019-11-18T12:02:58Z</dc:date>
    <item>
      <title>Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604955#M175461</link>
      <description>&lt;P&gt;I've&amp;nbsp; a data as follows in one dataset. Here the mechanism which I want to perform is, CURRENT_ID should be available in RISK_CURVE dataset and INSURANCE_CON. In similar way, GROUP_ID should be available in INSURANCE_CON_GRP and INSURANCE_CON dataset and so on. Here the base dataset is INSURANCE_CON.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case if there are some values which are not in base table (INSURANCE_CON)&amp;nbsp;but in reference table (INSURANCE_CON_GRP, RISK_CURVE) &amp;nbsp;then I've to capture that record in the Output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="892"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="556"&gt;&lt;STRONG&gt;Checks&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="336"&gt;&lt;STRONG&gt;TBL_NM&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;CURRENT_ID should be available in RISK_CURVE&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;GROUP_ID should be in INSURANCE_CON_GRP&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;LOCK_ID should be available in RISK_CURVE&lt;/TD&gt;
&lt;TD&gt;INSURANCE_CON&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output which I'm looking for,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="292"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="292"&gt;&lt;STRONG&gt;Fault_record_in_reference_table&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,M,Joseph,234&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11,F,Nakma,236&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although this mechanism sounds like a look up, challenge which I have is writing the&amp;nbsp;this validation &amp;nbsp;checks in macro as I've to insert this code in other macro code. Would be grateful if it can be accomplished&amp;nbsp;with minimal code.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604955#M175461</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-18T12:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604962#M175462</link>
      <description>&lt;P&gt;Please supply example data in usable form (data step(s) with datalines).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do multiple lookups in one pass, hash objects should be the way to go (provided that the lookup data fits into available memory).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604962#M175462</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T12:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604967#M175463</link>
      <description>&lt;P&gt;Could you please help me with one sample code for one look up?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604967#M175463</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-18T12:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604970#M175465</link>
      <description>&lt;P&gt;See an example using sashelp.class:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup;
input name $;
datalines;
Alfred
Jane
;

data want;
set sashelp.class;
if _n_ = 1
then do;
  declare hash lookup(dataset:"lookup");
  lookup.definekey("name");
  lookup.definedone();
end;
if lookup.find() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604970#M175465</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T12:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604996#M175478</link>
      <description>Well, my another question is how can we achieve it without using hashing?&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Nov 2019 13:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/604996#M175478</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-18T13:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605029#M175495</link>
      <description>&lt;P&gt;You could try formats, but those have inferior performance compared to hashes; other methods require sorts and multiple passes, or a hefty SQL (which does implicit sorts).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605029#M175495</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T14:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605101#M175527</link>
      <description>Got it! Could you please point me to one example where there is more than&lt;BR /&gt;one look up using hash or similar methods?&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605101#M175527</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-11-18T16:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605102#M175528</link>
      <description>&lt;P&gt;You just add additional hash objects from your tables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup1;
input name $;
datalines;
Alfred
Jane
;

data lookup2;
input age;
datalines;
14
;

data want;
set sashelp.class;
if _n_ = 1
then do;
  declare hash lookup1(dataset:"lookup1");
  lookup1.definekey("name");
  lookup1.definedone();
  declare hash lookup2(dataset:"lookup2");
  lookup2.definekey("age");
  lookup2.definedone();
end;
if lookup1.find() = 0 and lookup2.find() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 16:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605102#M175528</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T16:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro code for lookup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605108#M175533</link>
      <description>This looks like data quality management and not quite a look up problem. I'd probably recommend using SAS DI if you have it, or building a rules system that makes sense for you data. If your checks are all formated in the same way this isn't too difficult but it's definitely a project, not a forum solution.</description>
      <pubDate>Mon, 18 Nov 2019 17:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-code-for-lookup/m-p/605108#M175533</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-18T17:05:52Z</dc:date>
    </item>
  </channel>
</rss>

