<?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 Outer Apply available in proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Outer-Apply-available-in-proc-sql/m-p/258966#M50010</link>
    <description>&lt;P&gt;I have the following code which is based off a SQL query I use that I want to put into SAS via proc sql. &amp;nbsp;Is the outer apply function available in proc sql? &amp;nbsp;If not, how would one modify this code to work in proc sql?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;Drop Table AWM.temp4;&lt;BR /&gt;create table AWM.temp4 as&lt;BR /&gt;SELECT DISTINCT&lt;BR /&gt;r.*&lt;BR /&gt;,c.*&lt;BR /&gt;FROM AWM.temp3 r&lt;BR /&gt;OUTER APPLY (Select top 1 c.ScoreDt,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 35 THEN ISNULL(c.CreditScore,0) END AS TS,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 24 THEN ISNULL(c.CreditScore,0) END AS EX2,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 32 THEN ISNULL(c.CreditScore,0) END AS HF18,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 12 THEN ISNULL(c.CreditScore,0) END AS XPN1,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 20 THEN ISNULL(c.CreditScore,0) END AS JM1,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 34 THEN ISNULL(c.CreditScore,0) END AS DMS2&lt;BR /&gt;FROM Portrevw.VwCreditScoreFact c&lt;BR /&gt;where r.AccountDimId = c.AccountDimId&lt;BR /&gt;AND c.ScoreModelDimId IN (35,24,32,12,20,34)&lt;BR /&gt;AND c.ValidCalc = 1&lt;BR /&gt;AND c.ScoreDt &amp;gt; '01DEC2014'd&lt;BR /&gt;Order by c.ScoreDt desc) as c;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2016 20:45:30 GMT</pubDate>
    <dc:creator>awmeyertimmy</dc:creator>
    <dc:date>2016-03-24T20:45:30Z</dc:date>
    <item>
      <title>Outer Apply available in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outer-Apply-available-in-proc-sql/m-p/258966#M50010</link>
      <description>&lt;P&gt;I have the following code which is based off a SQL query I use that I want to put into SAS via proc sql. &amp;nbsp;Is the outer apply function available in proc sql? &amp;nbsp;If not, how would one modify this code to work in proc sql?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;Drop Table AWM.temp4;&lt;BR /&gt;create table AWM.temp4 as&lt;BR /&gt;SELECT DISTINCT&lt;BR /&gt;r.*&lt;BR /&gt;,c.*&lt;BR /&gt;FROM AWM.temp3 r&lt;BR /&gt;OUTER APPLY (Select top 1 c.ScoreDt,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 35 THEN ISNULL(c.CreditScore,0) END AS TS,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 24 THEN ISNULL(c.CreditScore,0) END AS EX2,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 32 THEN ISNULL(c.CreditScore,0) END AS HF18,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 12 THEN ISNULL(c.CreditScore,0) END AS XPN1,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 20 THEN ISNULL(c.CreditScore,0) END AS JM1,&lt;BR /&gt;Case WHEN c.ScoreModelDimId = 34 THEN ISNULL(c.CreditScore,0) END AS DMS2&lt;BR /&gt;FROM Portrevw.VwCreditScoreFact c&lt;BR /&gt;where r.AccountDimId = c.AccountDimId&lt;BR /&gt;AND c.ScoreModelDimId IN (35,24,32,12,20,34)&lt;BR /&gt;AND c.ValidCalc = 1&lt;BR /&gt;AND c.ScoreDt &amp;gt; '01DEC2014'd&lt;BR /&gt;Order by c.ScoreDt desc) as c;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 20:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outer-Apply-available-in-proc-sql/m-p/258966#M50010</guid>
      <dc:creator>awmeyertimmy</dc:creator>
      <dc:date>2016-03-24T20:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Outer Apply available in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outer-Apply-available-in-proc-sql/m-p/259571#M50227</link>
      <description>&lt;P&gt;APPLY is a SQL Server language extension. It is not available in SAS.&lt;/P&gt;&lt;P&gt;Whether SAS can give out the same result will depend on your data, a left join can usually replace OUTER APPLY.&lt;/P&gt;&lt;P&gt;See &lt;A href="https://www.mssqltips.com/sqlservertip/1958/sql-server-cross-apply-and-outer-apply/" target="_blank"&gt;https://www.mssqltips.com/sqlservertip/1958/sql-server-cross-apply-and-outer-apply/&lt;/A&gt; for an explanation.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2016 03:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outer-Apply-available-in-proc-sql/m-p/259571#M50227</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-03-29T03:04:33Z</dc:date>
    </item>
  </channel>
</rss>

