<?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 how to use vlookup equivalent in SAS for 2 datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-vlookup-equivalent-in-SAS-for-2-datasets/m-p/536483#M147434</link>
    <description>&lt;P&gt;Hi Please help my query.&lt;/P&gt;&lt;P&gt;I am using SAS studio. I have been trying to find a serial number match between two table and update the values of the numbers that match in a new column&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;ser_no x1 x2..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2&amp;nbsp;&lt;/P&gt;&lt;P&gt;ser_num x3 x4..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the ser_no from table1 is present in table 2 (ser_num column) then fill the same value in a new column 'Comparison' in Table 1.&lt;/P&gt;&lt;P&gt;This is equivalent to&amp;nbsp;=VLOOKUP(G1,$J:$J,1,0) G is ser_no (table1) J is ser_num from table2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried creating the entire column of table 2 in a macro variable.But nothing seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="error.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27259i514DCBEAFF82FC7C/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="error.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
 if _n_ eq 1 then do;
  if 0 then set table2;
  declare hash h(dataset:'table2');
  h.definekey('x3','x4');
  h.definedata('ser_num');
  h.definedone();
 end;
set table1;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Feb 2019 14:05:59 GMT</pubDate>
    <dc:creator>deep3</dc:creator>
    <dc:date>2019-02-18T14:05:59Z</dc:date>
    <item>
      <title>how to use vlookup equivalent in SAS for 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-vlookup-equivalent-in-SAS-for-2-datasets/m-p/536483#M147434</link>
      <description>&lt;P&gt;Hi Please help my query.&lt;/P&gt;&lt;P&gt;I am using SAS studio. I have been trying to find a serial number match between two table and update the values of the numbers that match in a new column&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;ser_no x1 x2..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table2&amp;nbsp;&lt;/P&gt;&lt;P&gt;ser_num x3 x4..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the ser_no from table1 is present in table 2 (ser_num column) then fill the same value in a new column 'Comparison' in Table 1.&lt;/P&gt;&lt;P&gt;This is equivalent to&amp;nbsp;=VLOOKUP(G1,$J:$J,1,0) G is ser_no (table1) J is ser_num from table2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried creating the entire column of table 2 in a macro variable.But nothing seems to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="error.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27259i514DCBEAFF82FC7C/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="error.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
 if _n_ eq 1 then do;
  if 0 then set table2;
  declare hash h(dataset:'table2');
  h.definekey('x3','x4');
  h.definedata('ser_num');
  h.definedone();
 end;
set table1;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Feb 2019 14:05:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-vlookup-equivalent-in-SAS-for-2-datasets/m-p/536483#M147434</guid>
      <dc:creator>deep3</dc:creator>
      <dc:date>2019-02-18T14:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to use vlookup equivalent in SAS for 2 datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-vlookup-equivalent-in-SAS-for-2-datasets/m-p/536494#M147437</link>
      <description>&lt;P&gt;Please show test data, in the form of a datastep.&amp;nbsp; It is not possible to diagnose a problem with a data based programming language without seeing data.&amp;nbsp; At a rough guess, I would just merge the two datasets together e.g.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have1 have2;
  by idvar;
  combined_var=coalsecec(varfromhave1,varfromhave2);
run;&lt;/PRE&gt;
&lt;P&gt;There are a lot of assumptions in there, both sorted by idvar, both has idvar, etc.&amp;nbsp; Again, without seeing data I couldn't possibly guess what you have.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 14:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-vlookup-equivalent-in-SAS-for-2-datasets/m-p/536494#M147437</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-18T14:24:36Z</dc:date>
    </item>
  </channel>
</rss>

