<?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 do I Vlookup in SAS EG without adding additional rows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360896#M64443</link>
    <description>&lt;P&gt;I would try the LEFT JOIN first, since that's likely easier in EG - especially if you're using the point and click tools, which it sounds like you are.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can post the code generated and a screen shot of the query we can help tailor it for what you need.&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 19:44:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-23T19:44:51Z</dc:date>
    <item>
      <title>How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360878#M64440</link>
      <description>&lt;P&gt;Using SAS EG 5.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two data sets. Data A is&amp;nbsp;a very large data pull (2Million + rows of data and 60+ columns). An example of some of these 60+ variables include Contract # , City, State, Volume, etc. Data B is a small excel file (~1000 rows and 2 columns). These two columns include Contract number and BCO.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am aiming to do is take Data A, add a new variable called "BCO 1". "BCO 1" will be the Data B BCO that associates with the corresponding Contract number. Verbadum what you would do when doing&amp;nbsp;a vlookup in excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attempted to do this via&amp;nbsp;the join tables query using a left join matching Contract # to Contract #. However, when I do this I end up with more rows than&amp;nbsp;I started with. Because I am looking at volume numbers, the extra rows skew my numbers incorrectly. I would like to simply vlookup a value into the BCO 1 column, while keeping the same amount of rows I began with.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360878#M64440</guid>
      <dc:creator>Amber_Nicole94</dc:creator>
      <dc:date>2017-05-23T19:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360881#M64441</link>
      <description>&lt;P&gt;This would be a LEFT (or RIGHT) JOIN in your query, depending on table order.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is, if you have multiple (many to many) matches you'll still end up with duplicates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there any duplicate keys in your 'lookup' table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, with such a small dataset I would recommend a PROC FORMAT. See Example 4 here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi30/001-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/001-30.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Along with the last examples that show how to create a format using a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - 2 million rows + 60 columns is still small data &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360881#M64441</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T19:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360887#M64442</link>
      <description>&lt;P&gt;In my lookup table (Data B) the Contract #'s are unique but the BCO has duplicates. For example one BCO could have 3 Contract #'s.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp;fairly new to SAS EG.&amp;nbsp;So to understand the PROC Format - I have my two&amp;nbsp;Excel Files imported into SAS EG. Then&amp;nbsp;I should click new &amp;gt; program to bring up the code window. How does the Program code change in terms of my data? Or is there a way to do PROC Format using the query builder?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360887#M64442</guid>
      <dc:creator>Amber_Nicole94</dc:creator>
      <dc:date>2017-05-23T19:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360896#M64443</link>
      <description>&lt;P&gt;I would try the LEFT JOIN first, since that's likely easier in EG - especially if you're using the point and click tools, which it sounds like you are.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can post the code generated and a screen shot of the query we can help tailor it for what you need.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 19:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360896#M64443</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T19:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360903#M64444</link>
      <description>&lt;P&gt;Original data has 2,207,926 rows. After join data has 2,208,343 rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have limited down the number of variables just so everything would fit in the screenshots. Left join and query snapshot in attachment. Code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%_eg_conditional_dropds(WORK.QUERY_FOR_APPEND_TABLE_0001_0001);

PROC SQL;
   CREATE TABLE WORK.QUERY_FOR_APPEND_TABLE_0001_0001(label="QUERY_FOR_APPEND_TABLE_0001") AS 
   SELECT t1.Volume, 
          t1.'Org City'n, 
          t1.'Org St'n, 
          t1.'Full Shipper Name'n, 
          t1.'Fiscal Year'n, 
          t1.'BO Name'n, 
          t1.'Freight Payor Contract #'n, 
          t2.BCO AS 'BCO 1'n
      FROM WORK.QUERY_FOR_APPEND_TABLE_0001_0000 t1
           LEFT JOIN WORK.MATCH_DATA t2 ON (t1.'Freight Payor Contract #'n = t2.'AGRT NUMBER'n);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2017 20:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360903#M64444</guid>
      <dc:creator>Amber_Nicole94</dc:creator>
      <dc:date>2017-05-23T20:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360905#M64445</link>
      <description>&lt;P&gt;Everything looks correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would double check your assumption that the lookup table doesn't have duplicate contract numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the Task for this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TASK&amp;gt;DATA&amp;gt;Sort Data&lt;/P&gt;
&lt;P&gt;Add contract number to the Sort By field&lt;/P&gt;
&lt;P&gt;Click Options in left hand menu&lt;/P&gt;
&lt;P&gt;Click "Keep Only the first record...."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check how the results differ.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 20:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360905#M64445</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T20:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360915#M64446</link>
      <description>&lt;P&gt;Wow! That was my problem. The rows are matching up perfectly now. I did have some duplicates in my agreement number afterall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 20:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360915#M64446</guid>
      <dc:creator>Amber_Nicole94</dc:creator>
      <dc:date>2017-05-23T20:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Vlookup in SAS EG without adding additional rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360917#M64447</link>
      <description>&lt;P&gt;You should verify why there are duplicates and how you need to deal with them.&lt;/P&gt;
&lt;P&gt;This will pull the duplicates out for you. How to deal with them is more a business problem than a coding problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by contractNo;
run;

data dups;
set have;
by contractNo;

if not (first.contractNo and last.contractNo);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2017 20:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-Vlookup-in-SAS-EG-without-adding-additional-rows/m-p/360917#M64447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-23T20:24:25Z</dc:date>
    </item>
  </channel>
</rss>

