<?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: Vlookup in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240095#M44265</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Thanks for your response, Please find the attached sample output that I need to get.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I tried doing this by using format and Joins but not getting desired output.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2015 20:06:48 GMT</pubDate>
    <dc:creator>Coa_SAs</dc:creator>
    <dc:date>2015-12-18T20:06:48Z</dc:date>
    <item>
      <title>Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240072#M44260</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having troble&amp;nbsp;to lookup values in SAS, I have a SAS dataset attached,&lt;/P&gt;
&lt;P&gt;I &amp;nbsp;Extracted NAICS2D,NAICS3D,NAICS4D,NAICS5D,NAICS6D&amp;nbsp;values by using substr function.I am having difficulty to look up the Title&amp;nbsp;for the same digit.I am doing vlookup&amp;nbsp;in Excel but due to large data set I am trying to do in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 19:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240072#M44260</guid>
      <dc:creator>Coa_SAs</dc:creator>
      <dc:date>2015-12-18T19:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240082#M44263</link>
      <description>You don't quit give us enough information to help you out. To do lookups in SAS you can use either a format or a join.  Depending on what your output is going to be, they each have their strong points.</description>
      <pubDate>Fri, 18 Dec 2015 19:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240082#M44263</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-18T19:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240095#M44265</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Thanks for your response, Please find the attached sample output that I need to get.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I tried doing this by using format and Joins but not getting desired output.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 20:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240095#M44265</guid>
      <dc:creator>Coa_SAs</dc:creator>
      <dc:date>2015-12-18T20:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240099#M44267</link>
      <description>What do you have? What are you trying to get to? Post what you've tried and isn't working.</description>
      <pubDate>Fri, 18 Dec 2015 20:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240099#M44267</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-18T20:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240101#M44268</link>
      <description>&lt;P&gt;Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Have Naics2d values 11,21,22,23,31,32,etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to get the Title for that, For eg :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Naics2d =11 then 'Agriculture, Forestry, Fishing and Hunting'&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If Naics2d=21 then 'Mining, Quarrying, and Oil and Gas Extraction' etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to code as below:&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt; CREATE TABLE WORK.QUERY_FOR_NAICS_OVERVIEW_0000 AS &lt;BR /&gt; SELECT t1.'NAICS US CODE'n, &lt;BR /&gt; t1.'INDUSTRY TITLE'n, &lt;BR /&gt; t1.NAICS2d, &lt;BR /&gt; t1.NAICS3d, &lt;BR /&gt; t1.NAICS4d, &lt;BR /&gt; t1.NAICS5d, &lt;BR /&gt; t1.NAICS6d, &lt;BR /&gt; t2.'INDUSTRY TITLE'n AS 'Naics2d.txt'n&lt;BR /&gt; FROM WORK.QUERY_FOR_NAICS_OVERVIEW t1&lt;BR /&gt; INNER JOIN WORK.QUERY_FOR_NAICS_OVERVIEW t2 ON (t1.'NAICS US CODE'n = t2.'NAICS US CODE'n);&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same as I need to get Title for Naics3d, Naics4d, Naics5d, Naics6d.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 20:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240101#M44268</guid>
      <dc:creator>Coa_SAs</dc:creator>
      <dc:date>2015-12-18T20:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240103#M44269</link>
      <description>&lt;P&gt;1) That was an Excel file, not a SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming your SAS data set is named have, the variables have some relationship to the column headings (note . isn't allowed in SAS data set variable&amp;nbsp;names), and that the NAICS variables are text and replacing the spaces in the column headings with _ as spaces aren'te allowed in variable names either (and I'm way too lazy to deal with the name literal syntax):&lt;/P&gt;
&lt;P&gt;It appears that each value of NAICS is associated with text, so a format is one way to use that information&lt;/P&gt;
&lt;P&gt;data makeformat;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (rename=(NAICS_US=Start Industry_Title=Label);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; FMTNAME="NCAICS";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; type="C";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; keep start label fmtname type;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc format cntlin=makeformat;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use with a put statement in a data step to assign the value.&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length NAICS2d_txt NAICS3d_txt $ 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAICS2d_txt = put(Naics2d,$NAICS.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAICS3d_txt = put(Naics3d,$NAICS.);&lt;/P&gt;
&lt;P&gt;/* left to the interested reader add the lines to get the rest*/&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR just use the format associated with the variables for any report procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bonus points for putting the format if needed later in a permanent library and finding the OPTION code to add the library to the format search path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 21:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240103#M44269</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-18T21:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Vlookup in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240106#M44270</link>
      <description>I echo &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; solution - use a format. &lt;BR /&gt;This is a multistage process. &lt;BR /&gt;First create a table that has all the mappings you need. These would be the reference tables. Then you can create formats from these tables using PROC FORMAT with CNTLIN. &lt;BR /&gt;&lt;BR /&gt;Here's a good reference paper on Proc Format. &lt;BR /&gt;&lt;BR /&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;BR /&gt;</description>
      <pubDate>Fri, 18 Dec 2015 20:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Vlookup-in-SAS/m-p/240106#M44270</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-18T20:45:34Z</dc:date>
    </item>
  </channel>
</rss>

