<?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: case when combining left join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801857#M315604</link>
    <description>&lt;PRE&gt;CASE 
WHEN A.ORG CODE IN ('251' '301' '302' '303') THEN 'HKG'
WHEN A.ORG_ CODE IN ('306' '307' '308' '309') THEN 'CHN'
ELSE 'MAC'
END AS PORTFOLIO&lt;/PRE&gt;
&lt;P&gt;this indicates that the result of the CASE WHEN will be a variable named PORTFOLIO &lt;/P&gt;</description>
    <pubDate>Sun, 13 Mar 2022 11:21:01 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-03-13T11:21:01Z</dc:date>
    <item>
      <title>case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801856#M315603</link>
      <description>&lt;PRE&gt;SELECT A.*,
CASE 
WHEN A.ORG CODE IN ('251' '301' '302' '303') THEN 'HKG'
WHEN A.ORG_ CODE IN ('306' '307' '308' '309') THEN 'CHN'
ELSE 'MAC'
END AS PORTFOLIO,
B.RELATIONSHIP NO,
B.IND_CENTRAL AS IND_CENTRAL,
B.PBI AS PBI_PIMIT,
B.CREDIT_LIMIT AS SAMP_CRLIM,
B.CURRENT_BAL AS SAMP_OS
FROM ACCT_NEW_ALL A
LEFT JOIN ACCT_LIST_SAMP B
ON AR.ORG_CODE=B.ORG_CODE
AND R.BCCOUNT_NO=B.ACCOUNT_NO;
QUIT;&lt;/PRE&gt;
&lt;P&gt;I understand case when and left join but putting together I cannot understand especially the line end as portfolio, I thought normally case when finish at the word end, now it continues with as portfolio and more, could you help me to interpret?&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 11:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801856#M315603</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-13T11:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801857#M315604</link>
      <description>&lt;PRE&gt;CASE 
WHEN A.ORG CODE IN ('251' '301' '302' '303') THEN 'HKG'
WHEN A.ORG_ CODE IN ('306' '307' '308' '309') THEN 'CHN'
ELSE 'MAC'
END AS PORTFOLIO&lt;/PRE&gt;
&lt;P&gt;this indicates that the result of the CASE WHEN will be a variable named PORTFOLIO &lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 11:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801857#M315604</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-13T11:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801858#M315605</link>
      <description>&lt;P&gt;then what is going on after the end as portfolio statement&lt;/P&gt;
&lt;P&gt;suddenly a few variable names and then some left join, how to read this left join statement?&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 11:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801858#M315605</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-13T11:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801860#M315606</link>
      <description>&lt;P&gt;This code will not run anyway, as it throws errors here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ON AR.ORG_CODE=B.ORG_CODE
AND R.BCCOUNT_NO=B.ACCOUNT_NO&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are no aliases AR or R in the FROM clause defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Shouting at the SAS interpreter won't improve things.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 12:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801860#M315606</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-13T12:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801861#M315607</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;then what is going on after the end as portfolio statement&lt;/P&gt;
&lt;P&gt;suddenly a few variable names and then some left join, how to read this left join statement?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could be specific and show us the LOG (the entire log for this PROC SQL) and point out the problems you see, instead of a vague question like "what is going on".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, from now on, when you ask questions, be specific; and when there is a problem, show us the ENTIRE log for this PROC or DATA step, don't make us ask.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 13:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801861#M315607</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-13T13:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: case when combining left join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801872#M315611</link>
      <description>&lt;P&gt;Formatting the code might help you read and understand it.&amp;nbsp; When you have to split a statement into multiple lines place the continuation character or keyword at the START of the new line where it will be easier for a human scanning the code to see it.&amp;nbsp; That includes the final semi-colon that marks the end of the statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT A.*
     , CASE WHEN A.ORG CODE IN ('251' '301' '302' '303') THEN 'HKG'
            WHEN A.ORG_ CODE IN ('306' '307' '308' '309') THEN 'CHN'
            ELSE 'MAC'
       END AS PORTFOLIO
     , B.RELATIONSHIP NO
     , B.IND_CENTRAL AS IND_CENTRAL
     , B.PBI AS PBI_PIMIT
     , B.CREDIT_LIMIT AS SAMP_CRLIM
     , B.CURRENT_BAL AS SAMP_OS
FROM ACCT_NEW_ALL A
LEFT JOIN ACCT_LIST_SAMP B
  ON AR.ORG_CODE=B.ORG_CODE
  AND R.BCCOUNT_NO=B.ACCOUNT_NO
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So now it is more obvious that the list separated by the commas is the list of variables to select.&amp;nbsp; A.* is all of the variables from dataset named A (or the dataset that is using the ALIAS of A).&amp;nbsp; Then the CASE..END statement value is being given the name of PORTFOLIO.&amp;nbsp; Then there is a list of other variables to select.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one that does not follow NAME AS NAME pattern is that B.RELATIONSHIP variable.&amp;nbsp; In that one the keyword AS is not present.&amp;nbsp; Did they want to use NO as the variable name?&amp;nbsp; Then it needs the AS keyword. If they meant NO as a LABEL then it needs the LABEL or LABEL= keyword.&amp;nbsp; Or did they just type a space instead of an underscore and the variable name should be RELATIONSHIP_NO?&amp;nbsp; Or are they using non-standard names and they should have used a name literal, like b.'RELATIONSHIP NO'n, in the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The ON condition is referencing variables from two datasets that are not part of the query.&amp;nbsp; AR and R.&amp;nbsp; Should those be changed to A?&amp;nbsp; Or are there more datasets that need to contribute to this query.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 16:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/case-when-combining-left-join/m-p/801872#M315611</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-13T16:43:07Z</dc:date>
    </item>
  </channel>
</rss>

