<?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 Help in merging two datasets based condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405852#M98751</link>
    <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and trying to write my new program in SAS and I am not able to proceed for a below situation. If anyone can guide on this issue, it will be a great help.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my requirement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one SAS dataset (dept) having below data. ( below data is actually coming from a DB2 table using PROD SQL).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE   DEPARTMENT&lt;/STRONG&gt; ..... 
100          CT        HR
200          ME        IT
300          VA        MR
400          NY        SL&lt;BR /&gt;500          CT        HR &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have another Db2 table(universal_table) having below data.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;UNIV_cd     UNIV_DESC&lt;/STRONG&gt;
CT          Connecticut
ME          Massachusetts
VA          Virginia 
NY          NewYork
HR          Human Resource
IT          Information Technology
MR          Marketing Research
SL          Sales&lt;/PRE&gt;&lt;P&gt;I want a final output like below..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE STATE_DESC     DEPARTMENT&lt;/STRONG&gt;  &lt;STRONG&gt;DEPART_DESC&lt;/STRONG&gt;
100          CT    Connecticut      HR       Human Resource
200          ME    Massachusetts    IT       Information Technology
300          VA    Virginia         MR       Marketing Research
400          NY    NewYork          SL       Sales&lt;BR /&gt;500          CT    Connecticut      HR       Human Resource &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any guidance to get this required result will be appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note: This is just a sample data. There are lot more columns present in dept dataset and I need to get the description from universal table for all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 01:55:50 GMT</pubDate>
    <dc:creator>batu544</dc:creator>
    <dc:date>2017-10-20T01:55:50Z</dc:date>
    <item>
      <title>Help in merging two datasets based condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405852#M98751</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and trying to write my new program in SAS and I am not able to proceed for a below situation. If anyone can guide on this issue, it will be a great help.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my requirement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one SAS dataset (dept) having below data. ( below data is actually coming from a DB2 table using PROD SQL).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE   DEPARTMENT&lt;/STRONG&gt; ..... 
100          CT        HR
200          ME        IT
300          VA        MR
400          NY        SL&lt;BR /&gt;500          CT        HR &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have another Db2 table(universal_table) having below data.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;UNIV_cd     UNIV_DESC&lt;/STRONG&gt;
CT          Connecticut
ME          Massachusetts
VA          Virginia 
NY          NewYork
HR          Human Resource
IT          Information Technology
MR          Marketing Research
SL          Sales&lt;/PRE&gt;&lt;P&gt;I want a final output like below..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE STATE_DESC     DEPARTMENT&lt;/STRONG&gt;  &lt;STRONG&gt;DEPART_DESC&lt;/STRONG&gt;
100          CT    Connecticut      HR       Human Resource
200          ME    Massachusetts    IT       Information Technology
300          VA    Virginia         MR       Marketing Research
400          NY    NewYork          SL       Sales&lt;BR /&gt;500          CT    Connecticut      HR       Human Resource &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any guidance to get this required result will be appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note: This is just a sample data. There are lot more columns present in dept dataset and I need to get the description from universal table for all.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 01:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405852#M98751</guid>
      <dc:creator>batu544</dc:creator>
      <dc:date>2017-10-20T01:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help in merging two datasets based condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405854#M98752</link>
      <description>&lt;P&gt;You're looking at match merging.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See examples and details here&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1tgk0uanvisvon1r26lc036k0w7.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n1tgk0uanvisvon1r26lc036k0w7.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, IMO, this is much easier in SQL.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=p0xbwe8mkbjx9zn1fkxw7skq9efd.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=sqlproc&amp;amp;docsetTarget=p0xbwe8mkbjx9zn1fkxw7skq9efd.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/match-merging-data-files-using-proc-sql/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/match-merging-data-files-using-proc-sql/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're still having issues please feel free to post your code and log, and detail any issues you're having.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: One key idea - you can list a table multiple times in a single SQL query so you can join on different fields at once in SQL. In a data step if you're merging on multiple values you need multiple data steps.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172709"&gt;@batu544&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am new to SAS and trying to write my new program in SAS and I am not able to proceed for a below situation. If anyone can guide on this issue, it will be a great help.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my requirement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one SAS dataset (dept) having below data. ( below data is actually coming from a DB2 table using PROD SQL).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE   DEPARTMENT&lt;/STRONG&gt; ..... 
100          CT        HR
200          ME        IT
300          VA        MR
400          NY        SL&lt;BR /&gt;500          CT        HR &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I have another Db2 table(universal_table) having below data.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;UNIV_cd     UNIV_DESC&lt;/STRONG&gt;
CT          Connecticut
ME          Massachusetts
VA          Virginia 
NY          NewYork
HR          Human Resource
IT          Information Technology
MR          Marketing Research
SL          Sales&lt;/PRE&gt;
&lt;P&gt;I want a final output like below..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;ID_CD       STATE STATE_DESC     DEPARTMENT&lt;/STRONG&gt;  &lt;STRONG&gt;DEPART_DESC&lt;/STRONG&gt;
100          CT    Connecticut      HR       Human Resource
200          ME    Massachusetts    IT       Information Technology
300          VA    Virginia         MR       Marketing Research
400          NY    NewYork          SL       Sales&lt;BR /&gt;500          CT    Connecticut      HR       Human Resource &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Any guidance to get this required result will be appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note: This is just a sample data. There are lot more columns present in dept dataset and I need to get the description from universal table for all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;pk&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 02:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405854#M98752</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-20T02:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help in merging two datasets based condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405873#M98765</link>
      <description>&lt;P&gt;Thanks for reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to merge the table by using proc sql, but issue is I need to do the join for more than 100 times to get the description for all those fields. Is there any other way&amp;nbsp; like macros or something ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 06:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405873#M98765</guid>
      <dc:creator>batu544</dc:creator>
      <dc:date>2017-10-20T06:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help in merging two datasets based condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405887#M98766</link>
      <description>&lt;P&gt;Create a format from your universal table and apply that. No sorting or joining needed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cntlin;
set universal_table (rename=(univ_cd=start univ_desc=label));
retain type 'C' fmtname 'unifmt';
run;

proc format library=work cntlin=cntlin;
run;

data final_output;
set dept;
state_desc = put(state,$unifmt.);
depart_desc = put(department,$unifmt.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2017 07:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/405887#M98766</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-20T07:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help in merging two datasets based condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/406212#M98868</link>
      <description>&lt;P&gt;Thank you KurtBremser .. It worked .. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2017 05:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-merging-two-datasets-based-condition/m-p/406212#M98868</guid>
      <dc:creator>batu544</dc:creator>
      <dc:date>2017-10-21T05:43:01Z</dc:date>
    </item>
  </channel>
</rss>

