<?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 MAX function in PROC SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660135#M78911</link>
    <description>&lt;P&gt;I am using max function to retrieve students' most recent active term and its associated enrollment credits. SAS log did not issue any error message but I keep getting Note: Table Work.Credit_Load created, with 0 rows and 9 columns. I am not sure what is wrong with the code, but each ID on table1 should have multiple enrollment terms even though their most recent active term varies. Anyone could help me with this? Thanks.&lt;/P&gt;&lt;PRE&gt;proc sql;

create table Credit_Load as
select T1.*,
       E.Credit_Load as MostRecentTerm_HoursEnrolled,
	E.TERMID as Recent_Active_Term

from table1 T1
left join  Enrollments E on TI.ID = E.ID
where E.TERMID = (select max(E1.TERMID) from Enrollments E1
                                   where E1.ID = E.ID);
quit;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Jun 2020 18:29:28 GMT</pubDate>
    <dc:creator>xliu1</dc:creator>
    <dc:date>2020-06-16T18:29:28Z</dc:date>
    <item>
      <title>MAX function in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660135#M78911</link>
      <description>&lt;P&gt;I am using max function to retrieve students' most recent active term and its associated enrollment credits. SAS log did not issue any error message but I keep getting Note: Table Work.Credit_Load created, with 0 rows and 9 columns. I am not sure what is wrong with the code, but each ID on table1 should have multiple enrollment terms even though their most recent active term varies. Anyone could help me with this? Thanks.&lt;/P&gt;&lt;PRE&gt;proc sql;

create table Credit_Load as
select T1.*,
       E.Credit_Load as MostRecentTerm_HoursEnrolled,
	E.TERMID as Recent_Active_Term

from table1 T1
left join  Enrollments E on TI.ID = E.ID
where E.TERMID = (select max(E1.TERMID) from Enrollments E1
                                   where E1.ID = E.ID);
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660135#M78911</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2020-06-16T18:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: MAX function in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660141#M78912</link>
      <description>&lt;P&gt;That code won't run at all, you have two incorrect aliases (TI and E1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the&amp;nbsp;&lt;EM&gt;complete&lt;/EM&gt; log of the SQL step&amp;nbsp;&lt;STRONG&gt;as is&lt;/STRONG&gt; by copy/pasting into a &amp;lt;/&amp;gt; window.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660141#M78912</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-16T18:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: MAX function in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660143#M78913</link>
      <description>&lt;P&gt;Here is the original SAS log:&lt;/P&gt;&lt;P&gt;825 proc sql;&lt;BR /&gt;826&lt;BR /&gt;827 create table ncha_Demo_InactiveStudents as&lt;BR /&gt;828 select I.*,&lt;BR /&gt;829 E.CURR_TERM_CRS_LOAD as MostRecentTerm_HoursEnrolled,&lt;BR /&gt;830 E.TERMID&lt;BR /&gt;831&lt;BR /&gt;832 from NCHA_PIDM I&lt;BR /&gt;833 left join Sid.SID_Enrollments_All_Vw(dbkey=(OASIS_PIDM)) E on I.GOREMAL_PIDM = E.OASIS_PIDM&lt;BR /&gt;834 where E.BENCH = 'E' and E.TERMID = (select max(E1.TERMID) from Sid.SID_Enrollments_All_Vw E1&lt;BR /&gt;835 where E1.OASIS_PIDM = E.OASIS_PIDM);&lt;BR /&gt;NOTE: Table WORK.NCHA_DEMO_INACTIVESTUDENTS created, with 0 rows and 9 columns.&lt;/P&gt;&lt;P&gt;836&lt;BR /&gt;837&lt;BR /&gt;838&lt;BR /&gt;839 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 1:16.55&lt;BR /&gt;cpu time 0.10 seconds&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660143#M78913</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2020-06-16T18:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: MAX function in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660150#M78914</link>
      <description>&lt;P&gt;Try starting with something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Credit_Load as
select 
	T1.*,
    E.Credit_Load as MostRecentTerm_HoursEnrolled,
	E.TERMID as Recent_Active_Term
from 
	table1 as T1 inner join  
	Enrollments as E on T1.ID = E.ID
group by E.ID
having E.TERMID = max(E.TERMID);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660150#M78914</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-16T18:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: MAX function in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660161#M78915</link>
      <description>&lt;P&gt;Thank you! it works out fine.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 19:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-function-in-PROC-SQL/m-p/660161#M78915</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2020-06-16T19:30:32Z</dc:date>
    </item>
  </channel>
</rss>

