<?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 Substitute value of column with other table. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365629#M86866</link>
    <description>&lt;P&gt;I have two tables, Table 1 containing below data:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Employee ID| designation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Salary &lt;BR /&gt;==========================================&lt;BR /&gt;0x3546789 | Software Engineer| 20000$&lt;BR /&gt;John &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Manager &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 40000$&lt;BR /&gt;0x762381 &amp;nbsp; | Analyst &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 30000$&lt;BR /&gt;Albert &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | DBA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 50000$&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and a reference table which contains the mapping of hexadecimal IDs to their corresponding values.&lt;/P&gt;
&lt;P&gt;Table 2:-&lt;BR /&gt;Employee ID| Name&lt;BR /&gt;==================&lt;BR /&gt;0x3546789 &amp;nbsp; | Keith&lt;BR /&gt;0x5423178 &amp;nbsp; | Charles&lt;BR /&gt;0x762381 &amp;nbsp; &amp;nbsp; | Andrew&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to resolve hexadecimal Employee ID to the names so that my final table looks like:-&lt;/P&gt;
&lt;P&gt;Employee ID| Designation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Salary &lt;BR /&gt;==========================================&lt;BR /&gt;Keith &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Software Engineer| 20000$&lt;BR /&gt;John &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Manager &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 40000$&lt;BR /&gt;Andrew &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Analyst &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 30000$&lt;BR /&gt;Albert &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | DBA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 50000$&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2017 11:13:22 GMT</pubDate>
    <dc:creator>Aditi24</dc:creator>
    <dc:date>2017-06-09T11:13:22Z</dc:date>
    <item>
      <title>Substitute value of column with other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365629#M86866</link>
      <description>&lt;P&gt;I have two tables, Table 1 containing below data:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Employee ID| designation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Salary &lt;BR /&gt;==========================================&lt;BR /&gt;0x3546789 | Software Engineer| 20000$&lt;BR /&gt;John &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Manager &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 40000$&lt;BR /&gt;0x762381 &amp;nbsp; | Analyst &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 30000$&lt;BR /&gt;Albert &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | DBA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 50000$&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and a reference table which contains the mapping of hexadecimal IDs to their corresponding values.&lt;/P&gt;
&lt;P&gt;Table 2:-&lt;BR /&gt;Employee ID| Name&lt;BR /&gt;==================&lt;BR /&gt;0x3546789 &amp;nbsp; | Keith&lt;BR /&gt;0x5423178 &amp;nbsp; | Charles&lt;BR /&gt;0x762381 &amp;nbsp; &amp;nbsp; | Andrew&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to resolve hexadecimal Employee ID to the names so that my final table looks like:-&lt;/P&gt;
&lt;P&gt;Employee ID| Designation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Salary &lt;BR /&gt;==========================================&lt;BR /&gt;Keith &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Software Engineer| 20000$&lt;BR /&gt;John &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Manager &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 40000$&lt;BR /&gt;Andrew &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Analyst &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 30000$&lt;BR /&gt;Albert &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | DBA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 50000$&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 11:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365629#M86866</guid>
      <dc:creator>Aditi24</dc:creator>
      <dc:date>2017-06-09T11:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Substitute value of column with other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365630#M86867</link>
      <description>&lt;P&gt;One easy way: &amp;nbsp;create a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data namelist;&lt;/P&gt;
&lt;P&gt;set table_2 end=done;&lt;/P&gt;
&lt;P&gt;retain fmtname '$name';&lt;/P&gt;
&lt;P&gt;start=employee_id;&lt;/P&gt;
&lt;P&gt;label=name;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;hlo='O';&lt;/P&gt;
&lt;P&gt;label='NOT FOUND';&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc format cntlin=namelist;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can apply the format to Table_1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set table_1;&lt;/P&gt;
&lt;P&gt;test_name = put(name, $name.);&lt;/P&gt;
&lt;P&gt;if test_name ne 'NOT FOUND' then name = test_name;&lt;/P&gt;
&lt;P&gt;drop test_name;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is untested, so minor tweaking might be necessary.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 11:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365630#M86867</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-09T11:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Substitute value of column with other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365633#M86870</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution with proc sql :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	CREATE TABLE WANT AS
	SELECT COALESCE(h2.Name,h1.ID) AS Name, h1.designation, h1.Salary
	FROM have1 h1
	LEFT JOIN have2 h2
	ON h2.ID=h1.ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 11:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365633#M86870</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-06-09T11:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Substitute value of column with other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365636#M86873</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
length Employee_ID $20 designation $30;
input Employee_ID$ designation$ Salary; 
datalines;
0x3546789 Software_Engineer 20000
John Manager 40000
0x762381 Analyst 30000
Albert DBA 50000
;

data table2;
length Employee_ID $20.;
input Employee_ID$ Name$;
datalines;
0x3546789 Keith
0x5423178 Charles
0x762381 Andrew
;

data want(drop = Name rc);
	length Name $20.;
	if _N_ = 1 then do;
		declare hash h(dataset:'table2');
		h.defineKey('Employee_ID');
		h.defineData('Name');
		h.defineDone();
	end;

	set table1;
	rc = h.find();
	
	if rc=0 then Employee_ID = Name;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 12:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-value-of-column-with-other-table/m-p/365636#M86873</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-09T12:32:18Z</dc:date>
    </item>
  </channel>
</rss>

