<?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: Breaking down of multiple left joins into different steps in Proc Sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374199#M89561</link>
    <description>&lt;P&gt;Post the log of your split queries.&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jul 2017 22:20:03 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2017-07-08T22:20:03Z</dc:date>
    <item>
      <title>Breaking down of multiple left joins into different steps in Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/373989#M89495</link>
      <description>&lt;P&gt;I got a code that uses a lot of left join with many tables. When I run this code, it takes more than an hour to run and at the end it gives error with Sort Execution Failure. So, I am thinking of breaking down that left join in multiple steps but I am not sure how to do it and need your help.&lt;/P&gt;&lt;P&gt;The code is as:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Proc sql;
create table newlib.Final_test as 
SELECT 
POpener.Name as Client,
Popener.PartyId as Account_Number,
Case
  When BalLoc.ConvertedRefNo NE '' then BalLoc.ConvertedRefNo
else BalLoc.Ourreferencenum
End as LC_Number,
BalLoc.OurReferenceNum ,
BalLoc.CnvLiabilityCode as Liability_Code,
POfficer.PartyID as Officer_Num,
POfficer.Name as Officer_Name,
POpener.ExpenseCode,
BalLoc.IssueDate as Issue_Date format=mmddyy10.,
BalLoc.ExpirationDate AS Expiry format=mmddyy10.,
BalLoc.LiabilityAmountBase as Total_LC_Balance,
Case
  When BalLoc.Syndicated = 0 Then BalLoc.LiabilityAmountBase
    else 0
End as SunTrust_Non_Syndicated_Exposure,
Case 
  When BalLoc.Syndicated = 1 and BalLoc.PartOutGroupPkey NE 0 Then    
BalLoc.LiabilityAmountBase
    else 0
  End as SunTrust_Syndicated_Exposure,
Case 
  When BalLoc.Syndicated = 1 and BalLoc.PartOutGroupPkey NE 0 Then   
(BalLoc.LiabilityAmountBase - (BalLoc.LiabilityAmountBase *   
(PParty.ParticipationPercent/100)))
  Else BalLoc.LiabilityAmountBase 
End as SunTrust_Exposure,
Case
  When BalLoc.Syndicated = 1 and BalLoc.PartOutGroupPkey &amp;lt;&amp;gt; 0 Then   
(BalLoc.LiabilityAmountBase  * PParty.ParticipationPercent/100)
  Else 0
End as Exposure_Held_By_Other_Banks,
PBene.Name as Beneficiary_Trustee,
cat(put(input(POpener.ObligorNumber,best10.),z10.),put(input 

   (BalLoc.CommitmentNumber,best10.),Z10.)) as Key,
case
when BalLoc.BeneCusip2 NE ' ' then catx 
('|',Balloc.BeneCusip,Balloc.BeneCusip2)
else BalLoc.BeneCusip
End as Cusip,
Case 
  when balLoc.OKtoExpire = 1 then '0' 
  when balLOc.OKtoExpire=0 and BalLoc.AutoExtTermDays NE 0 then put  
(Balloc.AutoExtTermDays,z3.)
  when balLoc.OKtoExpire=0 and BalLoc.AutoExtTermsMonth NE 0 then put  
(balloc.AutoExtTermsMonth,z3.)
  else '000'
End as Evergreen
Case 
when blf.AnnualRate NE 0 then put(blf.AnnualRate,z7.)
when blf.Amount NE 0 then cats('F',put(blf.amount,z7.))
else 'WAIVE'
End as Pricing,

FROM BalLocPrimary BalLoc
Left JOIN Party POpener on POpener.Pkey = BalLoc.OpenerPkey
Left join PartGroup PGroup on BallOC.PartOutGroupPkey = PGroup.pKey
Left join PartParties PParty ON PGroup.pKey = PParty.PartGroupPkey and   
PParty.ParticipationPercent &amp;gt; 0 and
PParty.combined in
(select PPartParties.All_combined  
from PPartParties /*group by PartGroupPkey, PartyPkey*/)

Left Join MemExpenseCodes ExpCodes on POpener.ExpenseCode = ExpCodes.Code
Left JOIN Party PBene on PBene.Pkey = BalLoc.BenePkey
Left join Party POfficer on POfficer.Pkey = BalLoc.AccountOfficerPkey 
left join maxfee on maxfee.LocPrimaryPkey = BalLoc.LocPrimaryPkey
left join BalLocFee BLF on BLF.Pkey = maxfee.pkey
Where BalLoc.LetterType not in ('STBA','EXPA', 'FEE',' ') and 
 BalLoc.LiabilityAmountBase &amp;gt; 0 and BalLoc.irdb = 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Shankar&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 14:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/373989#M89495</guid>
      <dc:creator>st_012</dc:creator>
      <dc:date>2017-07-07T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking down of multiple left joins into different steps in Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374070#M89512</link>
      <description>Splitting up this to several steps is - just work.&lt;BR /&gt;Someone thst was able to create this vast SQL step you should be able to split it up.</description>
      <pubDate>Fri, 07 Jul 2017 19:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374070#M89512</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-07T19:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking down of multiple left joins into different steps in Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374073#M89513</link>
      <description>&lt;P&gt;I break it into pieces but still that error "SORT EXECUTION FAILURE" appears. I know&amp;nbsp;that error&amp;nbsp;is a memory issue.&lt;/P&gt;&lt;P&gt;I am asking this question if there is other way we can write without needing much memory.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2017 19:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374073#M89513</guid>
      <dc:creator>st_012</dc:creator>
      <dc:date>2017-07-07T19:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking down of multiple left joins into different steps in Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374142#M89534</link>
      <description>&lt;A href="http://support.sas.com/kb/39/705.html" target="_blank"&gt;http://support.sas.com/kb/39/705.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If a join with only two tables fail, there are few other options than getting more resources. Be sure to carry only the necessary columns through each join, an shorten long char variables if possible.&lt;BR /&gt;As a last resort pre sort the data using PROC SORT TAGSORT and then use DATA step with MERGE.</description>
      <pubDate>Sat, 08 Jul 2017 03:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374142#M89534</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-08T03:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking down of multiple left joins into different steps in Proc Sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374199#M89561</link>
      <description>&lt;P&gt;Post the log of your split queries.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2017 22:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-down-of-multiple-left-joins-into-different-steps-in/m-p/374199#M89561</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-07-08T22:20:03Z</dc:date>
    </item>
  </channel>
</rss>

