* H:\sas\oracle\SIL\getSILdata.sas -- for all terms; * PN 2004/ ; * at term startup, create folder in h:\data\sil for term. run xlistcrns.sas getsubjects.sas; * extract session, meeting, instructor data for all sessions offered this term; * 4/28 modified to use meeting schedule type instead of base section sched type ; options nocenter errors=1 noxwait noxsync ls=80 obs=max compress=no; * location and name of output data files; filename course "h:\data\sil\YR200506\course.txt" lrecl=100; filename session "h:\data\sil\YR200506\session.txt" lrecl=137; filename meeting "h:\data\sil\YR200506\meeting.txt" lrecl=108; filename instr "h:\data\sil\YR200506\instr.txt" lrecl=140; filename pkgmap "h:\data\sil\YR200506\pkgmap.txt" lrecl=19; * files below are needed for part of year when we are running upcoming fall for rosters while completing prior year for ARS, starting about april ; filename course2 "h:\data\sil\YR200607\course.txt" lrecl=100; filename session2 "h:\data\sil\YR200607\session.txt" lrecl=137; filename meeting2 "h:\data\sil\YR200607\meeting.txt" lrecl=108; filename instr2 "h:\data\sil\YR200607\instr.txt" lrecl=140; filename pkgmap2 "h:\data\sil\YR200607\pkgmap.txt" lrecl=19; * read in parms with current academic term ; * all hardcoded data should be here; data _NULL_; call symput('faterm',"'120058%'") ; * fall term to select ; call symput('spterm',"'xxxxxx%'") ; * spring term to select, use 1---- until you want to process spring ; call symput('suterm',"'xxxxxx%'") ; * summer term to select, use 1---- until you begin summ proc ; call symput('fa2term',"'xxxxxx%'") ; * fall term to select during summer , use 1---- Aug to June ; call symput('GISterm',"'xxxxxx%'") ; * GIS term to select during summer , use 1---- Aug to June ; call symput('mappath',"'h:\data\sil\YR200506\'") ; call symput('mappath2',"'h:\data\sil\YR200607\'") ; * second year, needed Apr-Aug ; run; proc format; * need this to encode schedtype ; value $stype 'Bus Transportation '='BUS' 'Clinical Practice '='CLP' 'Conference '='CNF' 'Cooperative Education'='COP' 'Discussion/Recitation'='DIS' 'Flight '='FL' 'Independent Study '='IND' 'Laboratory '='LAB' 'Laboratory-Discussion'='LBD' 'Lecture '='LEC' 'Lecture-Discussion '='LCD' 'Online '='ONL' 'Packaged Section '='PKG' 'Practice '='PR' 'Quiz '='Q' 'Studio '='ST' 'Study Abroad '='STA' ; run; * get xlist secondary sections info from SQL server ; * this has one record per crn ; proc sql; %include 'h:\carol\personal\connections\SQL-dmiathenaCRS.inc'; *connect to SQLSERVR as crs (user=xxxxxx pass=xxxxxxx server='DMIATHENA' database='Course'); drop view xlistcrns; create view xlistcrns as select * from connection to crs (select distinct crn,term as term_cd from silxlist where (term like &faterm or term like &spterm or term like &suterm or term like &fa2term or term like &GISterm) and ctl_cd='N' order by term,crn ); disconnect from crs; quit; data secondry; * these are all the crns of secondary crosslists ; set xlistcrns; * it was faster to eliminate them in SAS than in SQL ; run; * "not in" constructs take hours due to inefficient processing paths ; ** get course info, section info from EDW ; PROC sql ; %include 'h:\carol\personal\connections\edwDirect.inc'; * has one statement; *connect to oracle as edw (user=xxxxxx orapw=xxxxxx path='dsprod01'); drop view session; create view session as select * from connection to EDW (select S.CRS_ID, S.CRS_SUBJ_CD as ctlsubject, S.CRS_NBR as ctlnbr, S.CRS_TITLE, S.SCHED_TYPE_CD as sect_sched_type, S.SCHED_TYPE_DESC, S.INSTRN_METHOD_CD, s.sect_nbr, s.SECT_GRADABLE_IND, 0 as package, S.TERM_CD, S.PART_OF_TERM_CD, S.PART_OF_TERM_DESC, S.SECT_STATUS_CD, s.crn as crnc, s.sect_link_id, nvl(SM.SESS_ASSIGN_CATGRY,'01') as sess_assign_catgry, nvl(SM.SCHED_TYPE_DESC,s.sched_type_desc) as mtg_sched_type_desc, nvl(SM.origchours, 0) as origchours, nvl(SM.CHOURS,0) as chours from edw.t_sect_base s left outer join (select TERM_CD, CRN, SESS_ASSIGN_CATGRY, SCHED_TYPE_DESC, /* cannot use code due to linked crses*/ max(sect_meeting_hour_nbr) as origchours, /* id any which are null*/ /* adjust contact hours for the number of weeks. 14 wks= full term*/ sum(SECT_MEETING_HOUR_NBR* (case when sect_end_dt-sect_start_dt>98 then 1 /* =14*7 */ else (sect_end_dt-sect_start_dt)/112 end )) as chours /* = 16*7 */ from edw.t_sect_meeting where (term_cd like &faterm or term_cd like &spterm or term_cd like &suterm or term_cd like &fa2term or term_cd like &GISterm) group by TERM_CD,CRN,SESS_ASSIGN_CATGRY,SCHED_TYPE_DESC) sm on (SM.crn=S.CRN and s.term_cd =sm.term_cd ) /* and S.SECT_STATUS_CD ='A' active,c=cancelled,d=drop,i=inactive,p=pending*/ where S.SCHED_TYPE_CD not like 'PKG%' /* PKG for packages, need to know this*/ and (s.term_cd like &faterm or s.term_cd like &spterm or s.term_cd like &suterm or s.term_cd like &fa2term or s.term_cd like &GISterm) order by s.term_cd,s.crn); drop view pkg; /* note: for packaged courses, ignore the session ids and use time/place */ create view pkg as select * from connection to EDW (select S.CRS_ID, S.CRS_SUBJ_CD as ctlsubject, S.CRS_NBR as ctlnbr, S.CRS_TITLE, S.SCHED_TYPE_CD as sect_sched_type, S.SCHED_TYPE_DESC, S.INSTRN_METHOD_CD, s.sect_nbr, s.SECT_GRADABLE_IND, 1 as package, m.TERM_CD, S.PART_OF_TERM_CD, S.PART_OF_TERM_DESC, s.sect_link_id, m.CRN as crnc, m.SESS_ASSIGN_CATGRY, m.SCHED_TYPE_DESC as mtg_sched_type_desc, /* cannot use sched type code due to linked crses*/ /* adjust contact hours for the number of weeks. 14 wks= full term*/ m.SECT_MEETING_HOUR_NBR as origchours, m.SECT_MEETING_HOUR_NBR* (case when m.sect_end_dt-m.sect_start_dt>98 then 1 else (m.sect_end_dt-m.sect_start_dt)/112 end ) as chours, m.BLDG_CD, m.BLDG_DESC, m.SECT_ROOM_NBR, SECT_MONDAY_MEET_IND as Mon, SECT_TUESDAY_MEET_IND as Tue, SECT_WEDNESDAY_MEET_IND as Wed, SECT_THURSDAY_MEET_IND as Thu, SECT_FRIDAY_MEET_IND as Fri, SECT_SATURDAY_MEET_IND as Sat, SECT_BGN_TIME, SECT_END_TIME, SECT_STATUS_CD from edw.t_sect_meeting m, edw.t_sect_base s where (m.term_cd like &faterm or m.term_cd like &spterm or m.term_cd like &suterm or m.term_cd like &fa2term or m.term_cd like &GISterm) and m.term_cd=s.term_cd and m.crn=s.crn /* and S.SECT_STATUS_CD ='A' active,c=cancelled,d=drop,i=inactive,p=pending*/ and S.SCHED_TYPE_CD like 'PKG%' order by m.term_cd,m.crn); drop view meeting; create view meeting as select * from connection to EDW (select m.CRN as crnc, m.SECT_SEQ_NBR, m.SESS_ASSIGN_CATGRY, m.sect_meeting_hour_nbr, m.SCHED_TYPE_DESC as mtg_sched_type_desc, m.TERM_CD, m.SECT_BGN_TIME, m.SECT_END_TIME, m.BLDG_CD, m.BLDG_DESC, m.SECT_ROOM_NBR, m.SECT_START_DT, m.SECT_END_DT, m.SECT_MONDAY_MEET_IND as Mon, m.SECT_TUESDAY_MEET_IND as Tue, m.SECT_WEDNESDAY_MEET_IND as Wed, m.SECT_THURSDAY_MEET_IND as Thu, m.SECT_FRIDAY_MEET_IND as Fri, m.SECT_SATURDAY_MEET_IND as Sat, s.crs_id, S.CRS_SUBJ_CD as ctlsubject, S.SCHED_TYPE_CD as sect_sched_type, S.SCHED_TYPE_DESC, S.CRS_NBR as ctlnbr from edw.t_sect_meeting m, edw.t_sect_base s where (m.term_cd like &faterm or m.term_cd like &spterm or m.term_cd like &suterm or m.term_cd like &fa2term or m.term_cd like &GISterm) and m.term_cd=s.term_cd and m.crn=s.crn order by m.term_cd,m.crn,sess_assign_catgry ); drop view courses; * get one record for course available this term with crosslisting info; * find the controlling course for it if it is not controlling; create view courses as select * from connection to edw (SELECT distinct c.term_cd, c.CRS_ID, c.CRS_SUBJ_CD as subject, c.CRS_NBR as nbr, c.crs_title, c.DEPT_CD as dept, c.DEPT_NAME as deptname, nvl(x.CROSS_LIST_CRS_CTRL_DEPT_CD,c.dept_cd) as ctl_dept, nvl(x.CROSS_LIST_CRS_CTRL_DEPT_NAME,c.dept_name) as ctl_deptname FROM edw.T_crs c left outer join EDW.T_CROSS_LIST_CRS X on (c.crs_id=x.crs_id and c.term_cd=x.term_cd and x.cross_list_crs_ctrl_cd='N') WHERE (c.term_cd like &faterm or c.term_cd like &spterm or c.term_cd like &suterm or c.term_cd like &fa2term or c.term_cd like &GISterm) order by c.term_cd,crs_id) ; drop view instr; * get all instructors assigned this term ; create view instr as select * from connection to EDW (select distinct p.uin,p.ssn,p.edw_pers_id, pers_fname as fname, pers_lname as lname, pers_mname as mname, i.CRN as crnc, i.SESS_ASSIGN_CATGRY, i.fac_assign_resp_pct as pct, i.primary_instr_ind as priminstr, i.FAC_INSTRN_ASSIGN_TYPE_CD, i.term_cd, s.PART_OF_TERM_CD, t.sess_tot_pct, t.fac_count, s.crs_id, s.CRS_SUBJ_CD as ctlsubject, s.CRS_NBR as ctlnbr, s.sect_nbr, e.empee_cls_cd as eclass, f.fac_tenure_cd as tenure /*A Indefinite Tenure, P Probationary/On Track, Q Probation, N Initial/Partial Term*/ from EDW.T_fac_sect_instrn_assign i left outer join (select crn,term_cd, sess_assign_catgry, sum(fac_assign_resp_pct) as sess_tot_pct, count(edw_pers_id) as fac_count from EDW.T_fac_sect_instrn_assign where (term_cd like &faterm or term_cd like &spterm or term_cd like &suterm or term_cd like &fa2term or term_cd like &GISterm) group by term_cd,crn,sess_assign_catgry) t on (i.crn=t.crn and i.term_cd=t.term_cd and i.sess_assign_catgry=t.sess_assign_catgry ) left outer join edw.t_pers_hist p on (i.edw_pers_id=p.edw_pers_id and p.pers_cur_info_ind='Y') left outer join edw.t_sect_base s on (i.crn=s.crn and i.term_cd=s.term_cd) left outer join edw.t_empee_hist e on (i.edw_pers_id=e.edw_pers_id and e.empee_cur_info_ind='Y') left outer join edw.t_fac_tenure_hist f on (i.edw_pers_id=f.edw_pers_id and f.fac_tenure_cur_info_ind='Y') where (i.term_cd like &faterm or i.term_cd like &spterm or i.term_cd like &suterm or i.term_cd like &fa2term or i.term_cd like &GISterm) order by i.term_cd,i.crn ); disconnect from EDW; quit; data meetings1; length sched_type_desc mtg_sched_type_desc $ 21. ; set meeting; crn=1*crnc; run; proc contents data=meetings1; run; data meetings2; merge meetings1(in=a) secondry(in=s); by term_cd crn ; if a and not s; run; data meetings2; set meetings2; sectstart=datepart(sect_start_dt); sectend=datepart(sect_end_dt); if sectend-sectstart>98 then chours=SECT_MEETING_HOUR_NBR; else chours=sect_meeting_hour_nbr*(sectend-sectstart)/112; weeks=(sectend-sectstart)/7; dow= mon||tue||wed||thu||fri||sat; *drop mon tue wed thu fri sat; * problem with change in edw ; if substr(SECT_BGN_TIME,4,1)='-' then SECT_BGN_TIME=' '||substr(SECT_BGN_TIME,1,3); if substr(SECT_END_TIME,4,1)='-' then SECT_END_TIME=' '||substr(SECT_END_TIME,1,3); if term_cd = substr(&fa2term,1,6) then file meeting2; else file meeting; put @01 crs_id $char07. @08 CRN 5. @13 ctlsubject $char04. @17 ctlnbr $char03. @20 SESS_ASSIGN_CATGRY $char02. @22 sect_meeting_hour_nbr 5.2 @27 SCHED_TYPE_desc $stype. /* from the section base SSASECT*/ @30 mtg_SCHED_TYPE_desc $stype. /* from the meeting */ @33 SECT_BGN_TIME $char04. /* 24-hour clock time*/ @37 SECT_END_TIME $char04. @41 BLDG_CD $char06. @47 BLDG_DESC $char18. @65 SECT_ROOM_NBR $char10. @75 SECTSTART mmddyy10. @85 SECTEND mmddyy10. @95 weeks 2. @97 dow $char06. @103 TERM_CD $char06. ; if sched_type_desc=:'Package' then idtype=put(mtg_sched_type_desc,$stype.); else idtype=put(sched_type_desc,$stype.); ** take sched type from section base unless it is packaged; run; proc sort; by term_cd crn idtype descending dow sect_bgn_time; data firstmtg (keep= term_cd crn idtype dow sect_bgn_time sect_end_time weeks sectstart sectend bldg_cd bldg_desc sect_room_nbr); set meetings2; by term_cd crn idtype descending dow sect_bgn_time; if first.idtype; run; * one rec/course offering; * sorted by term_cd crs_id, subject; data courses1; set courses; if dept=ctl_dept then ctl='C'; else ctl='N'; data ctl; set courses1; if ctl='C' ; ctlsubject=subject; ctlnbr=nbr; ctldept=dept; keep term_cd crs_id ctlsubject ctlnbr ctldept; run; proc sort data=ctl nodupkey; * make sure there are no dups; by term_cd crs_id; data courses2; merge courses1(in=a) ctl(in=b); by term_cd crs_id; if not b then do; ctlsubject=subject; ctlnbr=nbr; ctldept=dept; end ; run; data courses2; set courses2; if term_cd = substr(&fa2term,1,6) then file course2; else file course; put @01 CRS_ID $char07. @08 subject $char04. @12 nbr $char03. @15 DEPT $char04. /* this may be the controlling dept always*/ @18 ctlsubject $char04. @22 ctlnbr $char03. @25 ctldept $char04. @27 ctl $char01. /* N=noncontrolling C=controlling*/ @28 crs_title $char35. @95 term_cd $char06. ; ; run; data sessions1; * session view is non-packaged sections only ; length sched_type_desc mtg_sched_type_desc $ 21. ; set session; crn=1*crnc; run; data sessions2; * these are non-packaged, so use sched type from section; merge sessions1(in=a) secondry(in=s); by term_cd crn; if a and not s; idtype=put(sched_type_desc,$stype.); run; proc sort data=sessions2; by term_cd crn idtype; data sessions3; merge sessions2(in=a) firstmtg(in=b); by term_cd crn idtype; if a; * added 4/29/05 to elim duple records where idtype in meeting did not match section base; run; *** there were many problems with packaged courses, do not assume they are set up right; data pkg1; set pkg; crn=1*crnc; run; proc sort; by term_cd crn; * for packages, first eliminate secondary listings; * NOTE: packages should be in xlist table only if course is crosslisted ; * do not put into xlist the mapping of packaged sections, ; * e.g. Lec A to Lec B (other section of same course); data pkg2; merge pkg1(in=a) secondry(in=s); by term_cd crn; if a and not s; dow=mon||tue||wed||thu||fri||sat; run; ** next, we must use DOW, time, room, bldg to find and eliminate duplicates with diff CRNS. Use lowest CRN found, and contact hours on that record. ; ** Ex: crn schty meeting ; ** 11111 lec mw 10:00 DKH 100 ; ** 22222 lec mw 10:00 DKH 100 ; ** the 22222 lec must be mapped to the 11111 lec everywhere ; ** on the student rec on crstape, on the instr rec ; ** Must create a mapping table just like for crosslists. ; ** map ctl_crn-sched --> first_ctl_crn-sched ; proc sort data=pkg2; by term_cd ctlSUBJECT ctlnbr sess_assign_catgry mtg_SCHED_TYPE_DESC BLDG_CD SECT_ROOM_NBR DOW SECT_BGN_TIME CRN ; run; data pkg3 ; set pkg2; by term_cd ctlSUBJECT ctlnbr sess_assign_catgry mtg_SCHED_TYPE_DESC BLDG_CD SECT_ROOM_NBR DOW SECT_BGN_TIME; retain crn1 ; if first.SECT_BGN_TIME then crn1=crn; package=1; if term_cd = substr(&fa2term,1,6) then file pkgmap2; else file pkgmap; put @1 crn 5. @6 mtg_sched_type_desc $stype. @9 crn1 5. @14 term_cd $char06.; run; ** note: doesn't work if pkg has multiple meetings for a session; data pkg4; set pkg3; if crn=crn1; run; data allsess; set pkg4 sessions3; run; proc sort data=allsess; by crs_id crn; data allsess2; set allsess; if term_cd = substr(&fa2term,1,6) then file session2; else file session; put @01 crs_id $char07. @08 ctlsubject $char04. @12 ctlnbr $char03. @15 CRN 5. /* controlling crn */ @20 sect_nbr $char03. @23 SESS_ASSIGN_CATGRY $char02. @25 sched_type_desc $stype. @28 mtg_sched_type_desc $stype. @31 INSTRN_METHOD_CD $char04. @35 SECT_GRADABLE_IND $char01. @36 package 1. @37 PART_OF_TERM_CD $char06. @43 PART_OF_TERM_DESC $char10. @53 CHOURS 5.2 /* adjusted for weeks */ @58 sect_status_cd $char02. /*A% means active*/ @60 BLDG_CD $char06. /* first meeting of the week*/ @66 bldg_desc $char15. @81 SECT_ROOM_NBR $char10. @91 DOW $char06. @97 SECT_BGN_TIME $char04. @101 SECT_END_TIME $char04. @105 weeks 2. @107 sectstart yymmdd10. @117 sectend yymmdd10. @127 origchours 5.2 /* chours unadjusted for weeks - look for nulls*/ @132 TERM_CD $char06. ; run; proc sort data=allsess2; by crn sess_assign_catgry ; run; data instr1; set instr; * first, make sure pcts add up to 100 ; crn=1*crnc; if sess_tot_pct >0 and not(sess_tot_pct =100) then do; pct=pct*100/sess_tot_pct; sess_tot_pct=100; end; if part_of_term_cd='XM' then termtype='EX'; else termtype='TR'; if substr(term_cd,6,1)='7' then termtype='CC'; offload=' '; if termtype='EX' and (FAC_INSTRN_ASSIGN_TYPE_CD='OVCE' or FAC_INSTRN_ASSIGN_TYPE_CD='TDOV' ) then offload='Y'; if termtype='CC' then offload='Y'; select (tenure); when ('A') tensort=1; when ('P') tensort=2; when ('Q') tensort=3; otherwise tensort=4; end; length tenure_desc $ 12. ; if tenure='A' then tenure_desc='Tenured'; else if tenure='P' or tenure='Q' then tenure_desc='Tenure Track'; else tenure_desc='Nontenured'; run; proc sort ; * could have multiple tenure codes, want only one ; by term_cd crn sess_assign_catgry edw_pers_id tensort; data instr1a; set instr1; * tenured selected first, then probation, next Q ; by term_cd crn sess_assign_catgry edw_pers_id tensort; if first.edw_pers_id; run; data instr2; merge instr1a(in=a) secondry(in=s); by term_cd crn; if a and not s; run; proc sort data=instr2 ; by term_cd crn sess_assign_catgry descending priminstr; data instr3; * this code guarantees one primary ; set instr2; by term_cd crn sess_assign_catgry descending priminstr; if first.sess_assign_catgry then priminstr='Y'; else priminstr='N'; if sess_tot_pct>0 then adjpct=100*pct/sess_tot_pct; else adjpct=100; run; data instr3; set instr3; if adjpct>100 then adjpct=100; * had some oddities ; if term_cd = substr(&fa2term,1,6) then file instr2; else file instr; put @01 uin $char09. @10 ssn $char09. @19 edw_pers_id 7. @26 lname $char15. @41 fname $char15. @56 mname $char10. @66 crs_id $char07. @73 CRN 5. /* ctl dept crn. if pkg, lowest crn for this itype,sectn numbr */ @78 ctlsubject $char04. @82 ctlnbr $char03. @85 sect_nbr $char03. @88 SESS_ASSIGN_CATGRY $char02. @90 adjpct 6.2 @96 priminstr $char01. @97 FAC_INSTRN_ASSIGN_TYPE_CD $char04. @101 sess_tot_pct 6.2 @107 eclass $char02. @109 fac_count 2. @111 offload $char01. /* Y or blank */ @112 termtype $char02. /* TR EX CC */ @114 part_of_term_cd $char06. @120 term_cd $char06. @126 tenure_desc $char12. /*Tenured, Tenure Track, Nontenured*/ @140 'x' ; run ; options noxwait xsync; * noxwait closes the dos window when done; *xsync delays next SAS cmd until system cmd is done.; *xsync is needed to prevent DOS commands from piling up ; run; * -------------------------------------- current ARS year ; data _NULL_; path=&mappath ; filenm='course.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath ; filenm='session.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath ; filenm='meeting.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath ; filenm='instr.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath ; filenm='pkgmap.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; * ----------------------------------- next year, needed for June-Aug ; data _NULL_; path=&mappath2 ; filenm='course.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath2 ; filenm='session.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath2 ; filenm='meeting.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath2 ; filenm='instr.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run; data _NULL_; path=&mappath2 ; filenm='pkgmap.txt'; versions=5; %include 'h:\sas\utility\gdgupdt.inc' ; run;