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.
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;
Try starting with something like this:
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;
That code won't run at all, you have two incorrect aliases (TI and E1).
Please post the complete log of the SQL step as is by copy/pasting into a </> window.
Here is the original SAS log:
825 proc sql;
826
827 create table ncha_Demo_InactiveStudents as
828 select I.*,
829 E.CURR_TERM_CRS_LOAD as MostRecentTerm_HoursEnrolled,
830 E.TERMID
831
832 from NCHA_PIDM I
833 left join Sid.SID_Enrollments_All_Vw(dbkey=(OASIS_PIDM)) E on I.GOREMAL_PIDM = E.OASIS_PIDM
834 where E.BENCH = 'E' and E.TERMID = (select max(E1.TERMID) from Sid.SID_Enrollments_All_Vw E1
835 where E1.OASIS_PIDM = E.OASIS_PIDM);
NOTE: Table WORK.NCHA_DEMO_INACTIVESTUDENTS created, with 0 rows and 9 columns.
836
837
838
839 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 1:16.55
cpu time 0.10 seconds
Try starting with something like this:
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;
Thank you! it works out fine.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.