<?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: How to merge two tables while giving variable values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78821#M22736</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You only want union these two datasets vertically by Account group?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data Have_1;
informat Current_date date9.;
Input Current_date&amp;nbsp;&amp;nbsp; Account_number $12-14 Arrears_Band $ 17-23&amp;nbsp; balance ;
Format Current_date date9.;
cards;
28FEB2010&amp;nbsp; 111&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 10
31MAR2010&amp;nbsp; 111&amp;nbsp; Current 20
31MAY2010&amp;nbsp; 111&amp;nbsp; 30 - 60 30
28FEB2010&amp;nbsp; 444&amp;nbsp; Current 40
31MAR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 50
30APR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 60
31MAY2010&amp;nbsp; 444&amp;nbsp; Current 70
30APR2010&amp;nbsp; 555&amp;nbsp; Current 80
31MAY2010&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 90
31AUG2011&amp;nbsp; 555&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 12
30SEP2011&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 0
31MAY2010&amp;nbsp; 666&amp;nbsp; Current 15
31AUG2011&amp;nbsp; 666&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 20
30SEP2011&amp;nbsp; 666&amp;nbsp; Current 30
;
run;

 

data Have_2;
informat Post_date date9.;
Input Post_date Account_number $12-14 Net_Write_off_total_USD;
Format Post_date date9.;
cards;
31AUG2010&amp;nbsp; 111&amp;nbsp; 50
30SEP2011&amp;nbsp; 555&amp;nbsp; 77
;
run;

data want;
 set have_1 have_2(in=inb&amp;nbsp; rename=(Post_date=Current_date Net_Write_off_total_USD=balance)) ;
 by Account_number;
 if inb then Arrears_Band='writoff ';
run;
proc sort data=want;by Account_number Current_date;run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2012 03:22:35 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-07-31T03:22:35Z</dc:date>
    <item>
      <title>How to merge two tables while giving variable values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78820#M22735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;Hi SAS Community,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;I have two tables (Have_1 and Have_2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Have_1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Current_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;Input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Current_date&amp;nbsp;&amp;nbsp; Account_number $&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;12&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;14&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Arrears_Band $ &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;17&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;23&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; balance ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;Format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Current_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;28FEB2010&amp;nbsp; 111&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAR2010&amp;nbsp; 111&amp;nbsp; Current 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 111&amp;nbsp; 30 - 60 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;28FEB2010&amp;nbsp; 444&amp;nbsp; Current 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30APR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 60&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 444&amp;nbsp; Current 70&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30APR2010&amp;nbsp; 555&amp;nbsp; Current 80&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 90&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31AUG2011&amp;nbsp; 555&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 666&amp;nbsp; Current 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31AUG2011&amp;nbsp; 666&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 20 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 666&amp;nbsp; Current 30 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Have_2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Post_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;Input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Post_date Account_number &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;12&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;14&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Net_Write_off_total_USD;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;Format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; Post_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;date9.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;31AUG2010&amp;nbsp; 111&amp;nbsp; 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: black; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 555&amp;nbsp; 77&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Question:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;I need to join these 2 tables so that I could get the answer below.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;Answer:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp; Final data set should be like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: red; font-size: 10pt;"&gt;Notice the 2 records from have_2 table are embedded within have_1 table in date sequence. And a value called “&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: red; font-size: 10pt;"&gt;writoff” was assigned.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;28FEB2010&amp;nbsp; 111&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAR2010&amp;nbsp; 111&amp;nbsp; Current 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 111&amp;nbsp; 30 - 60 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: red; font-size: 10pt;"&gt;31AUG2010&amp;nbsp; 111&amp;nbsp; writoff 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;28FEB2010&amp;nbsp; 444&amp;nbsp; Current 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;30APR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 60&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 444&amp;nbsp; Current 70&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;30APR2010&amp;nbsp; 555&amp;nbsp; Current 80&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 90&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31AUG2011&amp;nbsp; 555&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: #ffffc0; color: red; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 555&amp;nbsp; writoff 77&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31MAY2010&amp;nbsp; 666&amp;nbsp; Current 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;31AUG2011&amp;nbsp; 666&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 20 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;30SEP2011&amp;nbsp; 666&amp;nbsp; Current 30&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: green; font-size: 10pt;"&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;My approach:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;/*Transform unique ID from numeric to character*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have_2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; have_2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;char_account_number = put(account_number, &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;$7.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;) ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; account_number ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;rename&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; char_account_number=account_number ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;/*Carrying out a full outer join*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;select&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: teal; font-size: 10pt;"&gt;b.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; have_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;full&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;join&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; have_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;on a.Account_number=b.Account_number;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: #008000; font-size: 10pt;"&gt;Obviously this approach doesn’t give me what I want.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: #008000; font-size: 10pt;"&gt;I really appreciate if someone could help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;Mirisage&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 03:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78820#M22735</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2012-07-31T03:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables while giving variable values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78821#M22736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You only want union these two datasets vertically by Account group?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data Have_1;
informat Current_date date9.;
Input Current_date&amp;nbsp;&amp;nbsp; Account_number $12-14 Arrears_Band $ 17-23&amp;nbsp; balance ;
Format Current_date date9.;
cards;
28FEB2010&amp;nbsp; 111&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 10
31MAR2010&amp;nbsp; 111&amp;nbsp; Current 20
31MAY2010&amp;nbsp; 111&amp;nbsp; 30 - 60 30
28FEB2010&amp;nbsp; 444&amp;nbsp; Current 40
31MAR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 50
30APR2010&amp;nbsp; 444&amp;nbsp; 30 - 60 60
31MAY2010&amp;nbsp; 444&amp;nbsp; Current 70
30APR2010&amp;nbsp; 555&amp;nbsp; Current 80
31MAY2010&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 90
31AUG2011&amp;nbsp; 555&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 12
30SEP2011&amp;nbsp; 555&amp;nbsp; NPNA&amp;nbsp;&amp;nbsp;&amp;nbsp; 0
31MAY2010&amp;nbsp; 666&amp;nbsp; Current 15
31AUG2011&amp;nbsp; 666&amp;nbsp; 90 +&amp;nbsp;&amp;nbsp;&amp;nbsp; 20
30SEP2011&amp;nbsp; 666&amp;nbsp; Current 30
;
run;

 

data Have_2;
informat Post_date date9.;
Input Post_date Account_number $12-14 Net_Write_off_total_USD;
Format Post_date date9.;
cards;
31AUG2010&amp;nbsp; 111&amp;nbsp; 50
30SEP2011&amp;nbsp; 555&amp;nbsp; 77
;
run;

data want;
 set have_1 have_2(in=inb&amp;nbsp; rename=(Post_date=Current_date Net_Write_off_total_USD=balance)) ;
 by Account_number;
 if inb then Arrears_Band='writoff ';
run;
proc sort data=want;by Account_number Current_date;run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 03:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78821#M22736</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-31T03:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables while giving variable values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78822#M22737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same suggestion as KSharp but, if your data is already in account_number date order, you can avoid the extra sort by including date as a 2nd by variable.&amp;nbsp; i.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; have_1 have_2(in=inb&amp;nbsp; rename=(Post_date=Current_date Net_Write_off_total_USD=balance)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; Account_number Current_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; inb &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; Arrears_Band=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'writoff '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 04:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78822#M22737</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-07-31T04:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two tables while giving variable values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78823#M22738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ksharp and Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Splendid! Work well. A lot of things to&amp;nbsp; learn.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mirisage&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 19:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-two-tables-while-giving-variable-values/m-p/78823#M22738</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2012-07-31T19:34:31Z</dc:date>
    </item>
  </channel>
</rss>

