<?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 To join multiple tables in SAS EG about 5 tables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510049#M32401</link>
    <description>&lt;P&gt;To join multiple tables in SAS EG about 5 tables&amp;nbsp; the primary key is different in some so cannot join. The report is prepared in excel and have to replicate it but the fields are set up in different tables. Can you show me a query where I can perform joins, where the primary key is missing in some cannot&amp;nbsp; join them.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Nov 2018 20:10:25 GMT</pubDate>
    <dc:creator>Sultana</dc:creator>
    <dc:date>2018-11-02T20:10:25Z</dc:date>
    <item>
      <title>To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510049#M32401</link>
      <description>&lt;P&gt;To join multiple tables in SAS EG about 5 tables&amp;nbsp; the primary key is different in some so cannot join. The report is prepared in excel and have to replicate it but the fields are set up in different tables. Can you show me a query where I can perform joins, where the primary key is missing in some cannot&amp;nbsp; join them.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 20:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510049#M32401</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2018-11-02T20:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510053#M32402</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244224"&gt;@Sultana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;To join multiple tables in SAS EG about 5 tables&amp;nbsp; the primary key is different in some so cannot join. The report is prepared in excel and have to replicate it but the fields are set up in different tables. Can you show me a query where I can perform joins, where the primary key is missing in some cannot&amp;nbsp; join them.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you post some examples of how you want that to be handled? If the key isn't there what record gets matched? Or what gets included. Please show what you have as starting data and what you want as output and explain the logic, then we can either suggest an approach or code. But without more information this is a vague question, which gets a vague answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To include data please see:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 20:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510053#M32402</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-02T20:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510592#M32406</link>
      <description>Well the Tables are Market- marketdescription&lt;BR /&gt;Branch -Branch Number&lt;BR /&gt;officer- OfficerName&lt;BR /&gt;loan-Customer number,&lt;BR /&gt;customername&lt;BR /&gt;account -Accountnumber&lt;BR /&gt;Fact Loan-original&lt;BR /&gt;balance,Adjusted Balance, Dayspast due.&lt;BR /&gt;Probability-Probabilityof&lt;BR /&gt;Defaultcode&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;These are the 7 VA tables and the eight table have to take from the source&lt;BR /&gt;table from which Pastdue is required.&lt;BR /&gt;&lt;BR /&gt;Now Factloan and loan has common field as the account key&lt;BR /&gt;and Account and Factloan has the common field Account key.&lt;BR /&gt;&lt;BR /&gt;Branch and loan has branch has common field Branch key.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this code&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.QUERY_FOR_DIM_LOAN AS&lt;BR /&gt;SELECT t1.CustomerNumber,&lt;BR /&gt;t1.CustomerIBCifNumber,&lt;BR /&gt;t2.AdjustedBalance,&lt;BR /&gt;t2.DaysPastDue,&lt;BR /&gt;t2.OriginalBalance,&lt;BR /&gt;t3.AccountNumber&lt;BR /&gt;FROM TMP00001.dim_loan t1, TMP00001.fact_loan_balance t2,&lt;BR /&gt;TMP00001.dim_account t3&lt;BR /&gt;WHERE (t1.AccountKey = t2.AccountKey AND t1.AccountKey =&lt;BR /&gt;t3.AccountKey);&lt;BR /&gt;QUIT;&lt;BR /&gt;Gives me the result for the selected ones.&lt;BR /&gt;This I do with SASEG query but if I do with left join,&lt;BR /&gt;libname Autoload 'F:\sasdata\data\autoload\report_mart_auto_load';&lt;BR /&gt;proc sql ;&lt;BR /&gt;create table Test as&lt;BR /&gt;Select&lt;BR /&gt;a.OriginalBalance,&lt;BR /&gt;a.DaysPastDue,&lt;BR /&gt;a.AdjustedBalance,&lt;BR /&gt;b.LoanNumber,&lt;BR /&gt;c.Officername,&lt;BR /&gt;a.timeid&lt;BR /&gt;from Autoload.Fact_Loan_Balance a&lt;BR /&gt;left join Autoload.dim_loan b on a.Accountkey=b.Accountkey&lt;BR /&gt;left join Autoload.dim_officer c on b.OfficerKey=c.Officerkey&lt;BR /&gt;where a.timeid = '20160200';&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The result is&lt;BR /&gt;[image: image.png]&lt;BR /&gt;&lt;BR /&gt;Please let me know how to move on&lt;BR /&gt;I need to get \&lt;BR /&gt;marketdescription BranchNumbe&lt;BR /&gt;OfficerName CustomerIBCifNumber&lt;BR /&gt;AccountNumber CustomerName OriginalBalance&lt;BR /&gt;AdjustedBalance ProbabilityOfDefaultCode&lt;BR /&gt;DaysPastDue Past Due&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In my final dataset from all the dataset mentioned above.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sultana&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2018 20:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510592#M32406</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2018-11-05T20:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510597#M32407</link>
      <description>No images were included. If you want more fields, add them to the SELECT list.&lt;BR /&gt;&lt;BR /&gt;It seems like you do have key variables and not seeing what the issue given what's been posted so far. It may be easier to use the EG query builder where you can see how the tables are joined and control the fields and joins more easily, especially if you understand the data. Then look at the generated code and pull that into your process if desired.</description>
      <pubDate>Mon, 05 Nov 2018 21:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510597#M32407</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-05T21:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510599#M32408</link>
      <description>I do not have the common variables for market , branch and officer.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2018 21:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510599#M32408</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2018-11-05T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510600#M32409</link>
      <description>You have to have a common variable, though they may not have the same name.</description>
      <pubDate>Mon, 05 Nov 2018 21:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510600#M32409</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-05T21:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510604#M32410</link>
      <description>Can you write a query for me for the tables as a sample which I can refer&lt;BR /&gt;to as like I did not understand *though they may not have the same name*&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2018 21:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510604#M32410</guid>
      <dc:creator>Sultana</dc:creator>
      <dc:date>2018-11-05T21:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510610#M32411</link>
      <description>I don't know the columns or relationships so that's literally impossible. But I'm guessing a key in one table may be something like Branch Code vs Branch Number in another table. It sounds like you're working with a relational DB so you're looking for what may be called foreign keys to the DBs.</description>
      <pubDate>Mon, 05 Nov 2018 21:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510610#M32411</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-05T21:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: To join multiple tables in SAS EG about 5 tables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510642#M32414</link>
      <description>&lt;P&gt;Before you get into a complex query, perhaps a simple example might clarify things a bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a simple one-to-many join that shows the idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Customers;
length CustomerID 8 CustomerName $20 ContactName $20 Address $30 City $15 PostalCode $10 Country $10;
input CustomerID &amp;amp; CustomerName &amp;amp; ContactName &amp;amp; Address &amp;amp; City &amp;amp; PostalCode &amp;amp; Country &amp;amp;;
cards;
1  Alfreds Futterkiste  Maria Anders  Obere Str. 57  Berlin  12209  Germany
2  Ana Trujillo Emparedados y helados  Ana Trujillo  Avda. de la Constitución 2222  México D.F.  05021  Mexico
3  Antonio Moreno Taquería  Antonio Moreno  Mataderos 2312  México D.F.  05023  Mexico
run;

data Orders;
informat OrderDate yymmdd10.;
input OrderID CustomerNumber EmployeeID OrderDate ShipperID;
cards;
10308  2  7  1996-09-18  3
10309  37  3  1996-09-19  1
10310  77  8  1996-09-20  2
10311  2  9  1996-09-21  4
run;

proc sql noprint;
create table OrdersAndCustomers as
select Orders.OrderID, Orders.OrderDate, Customers.CustomerID, Customers.CustomerName
from Orders inner join Customers on Orders.CustomerNumber = Customers.CustomerID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Nov 2018 23:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/To-join-multiple-tables-in-SAS-EG-about-5-tables/m-p/510642#M32414</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-11-05T23:16:03Z</dc:date>
    </item>
  </channel>
</rss>

