<?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: Vlook up function in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281889#M57202</link>
    <description>&lt;P&gt;The proc format approach doesn't care at all about how many data records are involved. It essentially is the same as saying "show a value with 2 decimal places". Other approaches, either with Proc Sql or a hash object actually look at data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Proc Sql method is basically a Join on a key value and looks something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sql;
   create table want as
   select dataset.*, lookup.value
   from dataset left join lookup
      on dataset.keyvariable=lookup.keyvariable;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where dataset represents the name of your dataset, lookup is the name of the dataset with the value you want to bring in and keyvariable is a variable that contains the identifying values. The name of the keyvariable does not have to be the same but the values do. If there are capitalization issues in spelling (city vs City vs CITY) then you could use UPCASE function to get them to match.&lt;/P&gt;</description>
    <pubDate>Sun, 03 Jul 2016 07:27:14 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-07-03T07:27:14Z</dc:date>
    <item>
      <title>Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281883#M57197</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;3 variables in a dataset 1.&amp;nbsp; The&amp;nbsp;3 variables are Profit Center (e.g. 123456), Product (e.g.&amp;nbsp;A100)&amp;nbsp;and 2016 expense total (e.g. $100,000).&amp;nbsp; I have another 2 variables in a dataset 2; Profit Center and Group Name (e.g. ABCD).&lt;/P&gt;&lt;P&gt;I'm trying to pull Group Name from dataset 2 to dataset 1 based on Profit Center, like we can do with vlook up function in excel.&amp;nbsp; Can someone please help me code this?&lt;/P&gt;&lt;P&gt;I have repeated records in dataset 1, meaning same Profit Center appears multiple times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 06:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281883#M57197</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-07-03T06:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281884#M57198</link>
      <description>&lt;P&gt;You have quite a few options. My personal recommendation is proc format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This paper covers many of them. For a beginner I would recommend either a SQL join or proc format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2008/095-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/095-2008.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 06:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281884#M57198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-03T06:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281888#M57201</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for the link.&amp;nbsp; As I did nt even know how I can start, it definitely helped me.&amp;nbsp; But I researched Proc Format and it seems that's good if the DS has ~50K records?&amp;nbsp; I have more than 1M records, so not sure if this is good option.&amp;nbsp; What would you recomment to do vlookup in large data set in SAS?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SKP&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 07:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281888#M57201</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-07-03T07:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281889#M57202</link>
      <description>&lt;P&gt;The proc format approach doesn't care at all about how many data records are involved. It essentially is the same as saying "show a value with 2 decimal places". Other approaches, either with Proc Sql or a hash object actually look at data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Proc Sql method is basically a Join on a key value and looks something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sql;
   create table want as
   select dataset.*, lookup.value
   from dataset left join lookup
      on dataset.keyvariable=lookup.keyvariable;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where dataset represents the name of your dataset, lookup is the name of the dataset with the value you want to bring in and keyvariable is a variable that contains the identifying values. The name of the keyvariable does not have to be the same but the values do. If there are capitalization issues in spelling (city vs City vs CITY) then you could use UPCASE function to get them to match.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 07:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281889#M57202</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-03T07:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281891#M57203</link>
      <description>&lt;PRE&gt;
Give you an example:



data dataset1;
input ProfitCenter Product $ expense;
cards;
1234 A100 100
1231 A100 100
;
run;
data dataset2;
input ProfitCenter GroupName $;
cards;
1234 ABCD
;
run;

data want;
if _n_=1 then do;
 if 0 then set dataset2;
 declare hash h(dataset:'dataset2',hashexp:20);
 h.definekey('ProfitCenter');
 h.definedata('GroupName ');
 h.definedone();
end;
 set dataset1; 
 call missing(GroupName);
 rc=h.find();
 drop rc;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jul 2016 07:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281891#M57203</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-03T07:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281946#M57229</link>
      <description>ballardw&lt;BR /&gt;Thank you so much for your comment. I tried it and it worked as the way I wanted. If I need to look up a value based on multiple valuables, can I list them in "keyvariable" in the formula?&lt;BR /&gt;&lt;BR /&gt;Thank you again.&lt;BR /&gt;SKP</description>
      <pubDate>Mon, 04 Jul 2016 05:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281946#M57229</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-07-04T05:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281948#M57230</link>
      <description>&lt;P&gt;Yes, they can be added into the join condition.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a.keyvar1=b.keyvar1
AND 
a.keyvar2=b.keyvar2
AND
...
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jul 2016 06:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281948#M57230</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-04T06:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Vlook up function in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281950#M57231</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp; This definitely helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SKP&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 06:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlook-up-function-in-SAS/m-p/281950#M57231</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-07-04T06:20:55Z</dc:date>
    </item>
  </channel>
</rss>

