<?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 loop into a lookup table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783660#M249941</link>
    <description>So you're looking for codes in the second table that are not anywhere in the claims table?</description>
    <pubDate>Thu, 02 Dec 2021 15:28:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-12-02T15:28:24Z</dc:date>
    <item>
      <title>How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783633#M249926</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to pull the claims data with 20 procedure codes, and all the procedure codes are stored in a procedure code lookup table. Is there a simpler way to do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;proc sql;&lt;BR /&gt;create table claims_data as &lt;BR /&gt;select distinct a.patient_id&lt;BR /&gt;,a.claim_num&lt;BR /&gt;,a.service_dt&lt;BR /&gt;,pr1.proc_1_cd&lt;BR /&gt;,pr2.proc_2_cd&lt;BR /&gt;,pr3.proc_3_cd&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;,pr20.proc_20_cd&lt;BR /&gt;from claim_file a&lt;BR /&gt;left join proc_lookup on pr1 on a.proc_1_cd_id=pr1.proc_cd_id&lt;BR /&gt;left join proc_lookup on pr2 on a.proc_2_cd_id=pr2.proc_cd_id&lt;BR /&gt;left join proc_lookup on pr3 on a.proc_3_cd_id=pr3.proc_cd_id&lt;/P&gt;
&lt;P&gt;...&lt;BR /&gt;;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the&amp;nbsp;procedure code lookup table, there are fields like this:&lt;/P&gt;
&lt;TABLE width="177"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="73"&gt;Field_num&lt;/TD&gt;
&lt;TD width="104"&gt;Field_Name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;PROC_CD_ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;PROC_CD_CD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;PROC_CD_DESC&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;PROC_CD_TYPE&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;PROC_CD_ID is the primary key.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all!&lt;/P&gt;
&lt;P&gt;Lizi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 14:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783633#M249926</guid>
      <dc:creator>lizzy28</dc:creator>
      <dc:date>2021-12-02T14:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783635#M249927</link>
      <description>Maybe a format? What information are you pulling from the procedure code table? The Description/Type?  &lt;BR /&gt;Can you show the full query - specifically the sections that pull data from the lookup table.</description>
      <pubDate>Thu, 02 Dec 2021 14:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783635#M249927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-02T14:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783658#M249940</link>
      <description>I just need to pull all the procedure codes which are not available in the claims file. But procedure code ids are available in the claims file.&lt;BR /&gt;&lt;BR /&gt;Here is the full query:&lt;BR /&gt; proc sql;&lt;BR /&gt;create table claims_data as&lt;BR /&gt;select distinct a.patient_id&lt;BR /&gt;,a.claim_num&lt;BR /&gt;,a.service_dt&lt;BR /&gt;,pr1.proc_1_cd&lt;BR /&gt;,pr2.proc_2_cd&lt;BR /&gt;,pr3.proc_3_cd&lt;BR /&gt;,pr4.proc_4_cd&lt;BR /&gt;,pr5.proc_5_cd&lt;BR /&gt;,pr6.proc_6_cd&lt;BR /&gt;,pr7.proc_7_cd&lt;BR /&gt;,pr8.proc_8_cd&lt;BR /&gt;,pr9.proc_9_cd&lt;BR /&gt;,pr10.proc_10_cd&lt;BR /&gt;,pr11.proc_11_cd&lt;BR /&gt;,pr12.proc_12_cd&lt;BR /&gt;,pr13.proc_13_cd&lt;BR /&gt;,pr14.proc_14_cd&lt;BR /&gt;,pr15.proc_15_cd&lt;BR /&gt;,pr16.proc_16_cd&lt;BR /&gt;,pr17.proc_17_cd&lt;BR /&gt;,pr18.proc_18_cd&lt;BR /&gt;,pr19.proc_19_cd&lt;BR /&gt;,pr20.proc_20_cd&lt;BR /&gt;from claim_file a&lt;BR /&gt;left join proc_lookup pr1 on a.proc_1_cd_id=pr1.proc_cd_id&lt;BR /&gt;left join proc_lookup pr2 on a.proc_2_cd_id=pr2.proc_cd_id&lt;BR /&gt;left join proc_lookup pr3 on a.proc_3_cd_id=pr3.proc_cd_id&lt;BR /&gt;left join proc_lookup pr4 on a.proc_4_cd_id=pr4.proc_cd_id&lt;BR /&gt;left join proc_lookup pr5 on a.proc_5_cd_id=pr5.proc_cd_id&lt;BR /&gt;left join proc_lookup pr6 on a.proc_6_cd_id=pr6.proc_cd_id&lt;BR /&gt;left join proc_lookup pr7 on a.proc_7_cd_id=pr7.proc_cd_id&lt;BR /&gt;left join proc_lookup pr8 on a.proc_8_cd_id=pr8.proc_cd_id&lt;BR /&gt;left join proc_lookup pr9 on a.proc_9_cd_id=pr9.proc_cd_id&lt;BR /&gt;left join proc_lookup pr10 on a.proc_10_cd_id=pr10.proc_cd_id&lt;BR /&gt;left join proc_lookup pr11 on a.proc_11_cd_id=pr11.proc_cd_id&lt;BR /&gt;left join proc_lookup pr12 on a.proc_12_cd_id=pr12.proc_cd_id&lt;BR /&gt;left join proc_lookup pr13 on a.proc_13_cd_id=pr13.proc_cd_id&lt;BR /&gt;left join proc_lookup pr14 on a.proc_14_cd_id=pr14.proc_cd_id&lt;BR /&gt;left join proc_lookup pr15 on a.proc_15_cd_id=pr15.proc_cd_id&lt;BR /&gt;left join proc_lookup pr16 on a.proc_16_cd_id=pr16.proc_cd_id&lt;BR /&gt;left join proc_lookup pr17 on a.proc_17_cd_id=pr17.proc_cd_id&lt;BR /&gt;left join proc_lookup pr18 on a.proc_18_cd_id=pr18.proc_cd_id&lt;BR /&gt;left join proc_lookup pr19 on a.proc_19_cd_id=pr19.proc_cd_id&lt;BR /&gt;left join proc_lookup pr20 on a.proc_20_cd_id=pr20.proc_cd_id&lt;BR /&gt;;quit;</description>
      <pubDate>Thu, 02 Dec 2021 15:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783658#M249940</guid>
      <dc:creator>lizzy28</dc:creator>
      <dc:date>2021-12-02T15:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783660#M249941</link>
      <description>So you're looking for codes in the second table that are not anywhere in the claims table?</description>
      <pubDate>Thu, 02 Dec 2021 15:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783660#M249941</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-02T15:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783663#M249943</link>
      <description>&lt;P&gt;Either create a format from the proc_lookup table, or read it into a hash object and use arrays and a DO loop to do the lookup.&lt;/P&gt;
&lt;P&gt;Example code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data proc_lookup;
input proc_cd_id proc_cd_cd $;
datalines;
1 x
2 y
3 z
;

data have;
input proc_1_cd_id proc_2_cd_id;
datalines;
1 1
2 3
1 2
;

data want;
set have;
array proc_id {2} proc_1_cd_id proc_2_cd_id;
array codes {2} $ proc_1_cd_cd proc_2_cd_cd;
if _n_ = 1
then do;
  length proc_cd_id 8 proc_cd_cd $8;
  declare hash l (dataset:"proc_lookup");
  l.definekey("proc_cd_id");
  l.definedata("proc_cd_cd");
  l.definedone();
end;
do i = 1 to 2;
  proc_cd_id = proc_id{i};
  if l.find() = 0 then codes{i} = proc_cd_cd;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Dec 2021 15:30:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783663#M249943</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-02T15:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783670#M249946</link>
      <description>Thank you, Kurt! But I need to use PROC SQL to pull data from a database. So data step doesn't work.</description>
      <pubDate>Thu, 02 Dec 2021 15:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783670#M249946</guid>
      <dc:creator>lizzy28</dc:creator>
      <dc:date>2021-12-02T15:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783673#M249949</link>
      <description>But procedure code ids are available in both files to join.</description>
      <pubDate>Thu, 02 Dec 2021 15:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783673#M249949</guid>
      <dc:creator>lizzy28</dc:creator>
      <dc:date>2021-12-02T15:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783681#M249954</link>
      <description>Instead of code, perhaps show us a small data sample, using say 5 codes and a short lookup table and show us what you need to accomplish will be more helpful. &lt;BR /&gt;</description>
      <pubDate>Thu, 02 Dec 2021 15:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783681#M249954</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-02T15:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783778#M250002</link>
      <description>&lt;P&gt;Here is a quick example of the lookup table:&lt;/P&gt;
&lt;TABLE width="521px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;PROC_CD_ID&lt;/TD&gt;
&lt;TD width="121.25px"&gt;PROC_CD&lt;/TD&gt;
&lt;TD width="147.609px"&gt;PROC_CD_DESC&lt;/TD&gt;
&lt;TD width="139.922px"&gt;PROC_CD_TYPE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;7096&lt;/TD&gt;
&lt;TD width="121.25px"&gt;86376&lt;/TD&gt;
&lt;TD width="147.609px"&gt;MICROSOMAL ANTIBODIES, EACH&lt;/TD&gt;
&lt;TD width="139.922px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;7098&lt;/TD&gt;
&lt;TD width="121.25px"&gt;86382&lt;/TD&gt;
&lt;TD width="147.609px"&gt;NEUTRALIZATION TEST, VIRAL&lt;/TD&gt;
&lt;TD width="139.922px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;7099&lt;/TD&gt;
&lt;TD width="121.25px"&gt;86384&lt;/TD&gt;
&lt;TD width="147.609px"&gt;NITROBLUE TETRAZOLIUM DYE TE&lt;/TD&gt;
&lt;TD width="139.922px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;7100&lt;/TD&gt;
&lt;TD width="121.25px"&gt;86403&lt;/TD&gt;
&lt;TD width="147.609px"&gt;PARTICLE AGGLUTINATION; SCRE&lt;/TD&gt;
&lt;TD width="139.922px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="114.141px"&gt;7102&lt;/TD&gt;
&lt;TD width="121.25px"&gt;86430&lt;/TD&gt;
&lt;TD width="147.609px"&gt;RHEUMATOID FACTOR; QUALITATI&lt;/TD&gt;
&lt;TD width="139.922px"&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first field&amp;nbsp;PROC_CD_ID is available in both the claim file and the lookup table while the second field PROC_CD is only available in the lookup table. I need to pull the field&amp;nbsp;PROC_CD through joining&amp;nbsp;PROC_CD_ID in both tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 20:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783778#M250002</guid>
      <dc:creator>lizzy28</dc:creator>
      <dc:date>2021-12-02T20:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783779#M250003</link>
      <description>That's one part. You need to show the full picture, which means an example (Fake data is fine) of the main table and most importantly - what you want as output. The output part, what are you asking about is the part that's unclear.</description>
      <pubDate>Thu, 02 Dec 2021 20:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783779#M250003</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-02T20:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783799#M250015</link>
      <description>&lt;P&gt;What database is that? A simpler approach would be for your DBA to create a view combining the 20 lookup tables, then you do one join to the view.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 23:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783799#M250015</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-02T23:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783862#M250050</link>
      <description>&lt;P&gt;You are working with SAS, so the data step is available.&lt;/P&gt;
&lt;P&gt;If, OTOH, this is to be done directly on the DB via explicit passthrough, consult the DBA's, or a community for that particular DB environment.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783862#M250050</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-03T09:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop into a lookup table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783966#M250096</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dlm=',';
informat ID $1. proc_1_cd proc_2_cd proc_3_cd proc_4_cd proc_5_cd $8.;
input ID $ proc_1_cd proc_2_cd proc_3_cd proc_4_cd proc_5_cd ;
cards;
A, 123.43, 124.34, 134.35, 124.89, 343.43
B, 423.43, 456.86, 129, 124.89, 145
C, 123.43, 124.34, 134.35, 124.89, 285.95
D, 854.70, 874.6,  68.55, 294.1, 4.5
E, 123.43, 124.34C, 134.35B, 124.89, 89.65A
;;;;
run;


proc sql;
create table distinct_codes as
select distinct proc_1_cd from have
union 
select distinct proc_2_cd from have
union 
select distinct proc_3_cd from have
union 
select distinct proc_4_cd from have
union 
select distinct proc_5_cd from have;
quit;



proc sql;
create table codes_not_found as
select * from lookup where proc_cd not in (select distinct proc_code from distinct_codes);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 17:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-loop-into-a-lookup-table/m-p/783966#M250096</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-03T17:19:30Z</dc:date>
    </item>
  </channel>
</rss>

