<?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: Help with PROC SQL syntax error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/721222#M80214</link>
    <description>&lt;P&gt;Not sure why you have a min() aggregate function around the case statement, and have no GROUP BY?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2021 09:58:51 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2021-02-23T09:58:51Z</dc:date>
    <item>
      <title>Help with PROC SQL syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/720976#M80210</link>
      <description>&lt;P&gt;I keep getting error message from sas log for the following program and will appreciate any help with this. Thanks!&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xliu1_0-1614014076263.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55034iE9EE17B796F3AEA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xliu1_0-1614014076263.png" alt="xliu1_0-1614014076263.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC SQL;
CREATE TABLE MIN_ENRL_TERM AS
SELECT H.OASIS_PIDM    as    OASIS_PIDM               
, R.UID              as   USF_ID
,(SELECT  H.REPT_TIME_FRAME as MIN_ENRL_TIME,
        H.OASIS_PIDM  as    MIN_ENRL_PIDM,
        min(CASE WHEN (H.STU_ENTRY_TYP IN ('B', 'E') AND H.STU_RECENT_ADM_TYP IN ('B', 'E') 
                         AND R.CRS_SYSTEM = 'N' AND R.CRS_GROUP = 'A' and R.STU_CLASS_LEVEL ^= 'N' 
                         AND R.TERM_TAKEN &amp;gt;= H.STU_ENTRY_DT) THEN R.TERM_TAKEN
                 WHEN (R.CRS_SYSTEM = 'N' AND R.CRS_GROUP = 'A' and R.STU_CLASS_LEVEL ^= 'N' 
                         AND R.TERM_TAKEN &amp;gt;= H.STU_RECENT_ADM_DT) THEN R.TERM_TAKEN END)) AS FIRST_ENRL_TERM
FROM SID.SID_COURSES_TO_DEGREE  R
JOIN SID.SID_HOURS_TO_DEGREE H ON R.CONTEXT_CODE = H.CONTEXT_CODE AND R.OASIS_PIDM = H.OASIS_PIDM 
                                  AND R.REPT_TIME_FRAME = H.REPT_TIME_FRAME AND R.REPT_TIME_FRAME IN ('201905', '201908', '202001');
QUIT;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 17:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/720976#M80210</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2021-02-22T17:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PROC SQL syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/720980#M80211</link>
      <description>&lt;P&gt;Your SQL has a subquery (sub-SELECT) that appears to select more than one column? But the FROM for that inner query isn't clear to me.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Also, you have a JOIN keyword but not an INNER or LEFT/RIGHT modifier.&amp;nbsp; Maybe this an acceptable shortcut but I haven't seen it before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When constructing SQL with an inner query, I advise testing out that inner query on its own first, getting it right, and then folding it into a larger query.&amp;nbsp; Usually an inner query returns just one value or a list of values that are used as a filter for the outer query.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 17:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/720980#M80211</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-02-22T17:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PROC SQL syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/721010#M80212</link>
      <description>&lt;P&gt;it looks like you are doing an inline select based on this screen shot with multiple columns being returned (MIN_ENRL_TIME, MIN_ENRL_PIDM...) and then trying to call the whole thing FIRST_ENRL_TERM.&amp;nbsp; I do not believe this is valid syntax.&amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 681px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55038i77B666ADCBF8BB6F/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 19:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/721010#M80212</guid>
      <dc:creator>utrocketeng</dc:creator>
      <dc:date>2021-02-22T19:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with PROC SQL syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/721222#M80214</link>
      <description>&lt;P&gt;Not sure why you have a min() aggregate function around the case statement, and have no GROUP BY?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 09:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-with-PROC-SQL-syntax-error/m-p/721222#M80214</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2021-02-23T09:58:51Z</dc:date>
    </item>
  </channel>
</rss>

