<?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 Multiple Columns to Lookup in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182729#M3711</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning, All.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got a table with five ID columns that I need to lookup their value of on another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say the columns are:&lt;/P&gt;&lt;P&gt;ID_1&lt;/P&gt;&lt;P&gt;ID_2&lt;/P&gt;&lt;P&gt;ID_3&lt;/P&gt;&lt;P&gt;ID_4&lt;/P&gt;&lt;P&gt;ID_5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking that I could use a loop transformation. First, set a control table with records 1-5, then iterate through a lookup job five times. The thing is, in that lookup job, how would I go about setting it up to find the value of ID_1 on the first iteration, then the value of ID_2 on the second, etc? As the lookup transformation requires mappings of columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this? Am I on the right path or is there a better solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd rather not repeat the same lookup step five times, which is why I was hoping to just loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Jan 2015 15:42:47 GMT</pubDate>
    <dc:creator>jwhite</dc:creator>
    <dc:date>2015-01-14T15:42:47Z</dc:date>
    <item>
      <title>Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182729#M3711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning, All.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got a table with five ID columns that I need to lookup their value of on another table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say the columns are:&lt;/P&gt;&lt;P&gt;ID_1&lt;/P&gt;&lt;P&gt;ID_2&lt;/P&gt;&lt;P&gt;ID_3&lt;/P&gt;&lt;P&gt;ID_4&lt;/P&gt;&lt;P&gt;ID_5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking that I could use a loop transformation. First, set a control table with records 1-5, then iterate through a lookup job five times. The thing is, in that lookup job, how would I go about setting it up to find the value of ID_1 on the first iteration, then the value of ID_2 on the second, etc? As the lookup transformation requires mappings of columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this? Am I on the right path or is there a better solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd rather not repeat the same lookup step five times, which is why I was hoping to just loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 15:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182729#M3711</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2015-01-14T15:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182730#M3712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;without knowing more about the table layouts...&amp;nbsp; You could also create a view.&amp;nbsp; Depending on the size of the lookup table and if it was a sas dataset or an external dbms table, a hash lookup might be faster but comes with more complexity.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;b.id_1,&lt;/P&gt;&lt;P&gt;t1.lookup as id_1_lookup,&lt;/P&gt;&lt;P&gt;b.id_2,&lt;/P&gt;&lt;P&gt;t2.lookup as id_2_lookup,&lt;/P&gt;&lt;P&gt;b.id_3,&lt;/P&gt;&lt;P&gt;t3.lookup as id_3_lookup&lt;/P&gt;&lt;P&gt;b.id_4,&lt;/P&gt;&lt;P&gt;t4.lookup as id_4_lookup,&lt;/P&gt;&lt;P&gt;b.id_5,&lt;/P&gt;&lt;P&gt;t5.lookup as id_5_lookup&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join lookup_table t1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on b.id_1=t1.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join lookup_table t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on b.id_2=t2.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join lookup_table t3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on b.id_3=t3.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join lookup_table t4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on b.id_4=t4.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left outer join lookup_table t5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on b.id_5=t5.id&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jan 2015 15:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182730#M3712</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2015-01-14T15:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182731#M3713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DBailey, this is a DI Studio problem, not a SAS programming one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JWhite, perhaps I don't see the whole picture, but building an iterations sounds unnecessary complicated, and ineffective. Not even sure if it could work without user written code.&lt;/P&gt;&lt;P&gt;You could do five look-up in the same transformation, just attach the look-up table five times.&lt;/P&gt;&lt;P&gt;The only (?) thing that could be a problem is that you will have the look-up tabled loaded in five copies in memory, so I hope it's not too large.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 15:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182731#M3713</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-01-16T15:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182732#M3714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up using five lookup transformations over user-written code, as it appears to be easier to read for any follow-up developers. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I just tried your trick of using five tables to one lookup transformation. That'll work as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea which method is better/more efficient? The both have redundancies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jan 2015 16:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182732#M3714</guid>
      <dc:creator>jwhite</dc:creator>
      <dc:date>2015-01-16T16:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182733#M3715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without seeing what you have done, I think have all look-up in the same transformation is the most efficient. Each look-up tansformation will add another table scan of your source data. If your memory is being exhausted by a single look-up, is the only reason that I could see for going with another solution.&lt;/P&gt;&lt;P&gt;But, to see the hard facts for your situation, try them out and compare. Just try to avoid user written code if possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jan 2015 20:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182733#M3715</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-01-17T20:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Columns to Lookup</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182734#M3716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand your data correctly then your look-up table consists of simple key/value pairs. Your base table has 5 columns with keys for which you need to look-up the value always using the same look-up table with the same key/value pairs. If this is correct then doing this job with a single look-up transformations (and 5 look-ups) is more efficient than 5 passes through the base table with a single look-up in each pass (in the end you still need to read the look-up table 5 times).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From a perspective of performance: You could in a user written node (may be implemented as a user written transformation) create a SAS format out of your look-up table and then simply apply this format to your ID variables. This would only require one pass through the look-up table when creating the format.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Jan 2015 01:05:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Multiple-Columns-to-Lookup/m-p/182734#M3716</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-01-18T01:05:50Z</dc:date>
    </item>
  </channel>
</rss>

