My task is to find the percent of the school year a student was enrolled. I need the number of weekdays that the student was enrolled in a particular school from their enterdate to their exitdate. That number will be divided by 180 to get the percent_enrolled. The school year starts on 8/1814 and ends on 6/4/15.
Sample data:
schoolid studentID enterdate exitdate
3 1 08/18/2014 06/04/2015
5 2 08/18/2014 10/21/2015
5 3 08/25/2014 10/07/2014
5 3 01/05/2014 06/04/2015
7 4 08/18/2014 10/01/2014
8 4 10/02/2014 01/05/2015
7 4 01/12/2015 06/04/2015
Student 1 is the easy case - the student enrolled on day 1 and stayed the entire school year, so his % enrollment is 180/180 = 100%
Student 2 entered on day 1 and unenrolled on Day 45. His % enrollment would be 45/180=25% but note that there are actually more than 45 week days between day 1 and day 45 due to Labor Day being a holiday. I'm assuming that some hard coding may have to be done to account for holidays that occur during weekdays.
Student 3 is presented to show there are multiple obs for some records. This student left school = 5 on 10/07 but re-enrolled in the same school on 01/05.
Student 4 is presented here to show that students may have enrollments at more than one school. So, this student will have a certain percentage attributed to school=7 and a separate percentage for school = 8.
Any help would be greatly appreciated since this is a little above my pay grade.
Gregg
Hi,
A combination of intck:
SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition
And this post (there are many others here on dates/holidays):
I think you have some typo .
schoolid studentID enterdate exitdate
3 1 08/18/2014 06/04/2015 <--- the number of weekdays should be 209
5 2 08/18/2014 10/21/2015 <----2014 <--- the number of weekdays should be 47
5 3 08/25/2014 10/07/2014
5 3 01/05/2014 <--2015 06/04/2015
7 4 08/18/2014 10/01/2014
8 4 10/02/2014 01/05/2015
7 4 01/12/2015 06/04/2015
The number would be 209 if there were no holidays. This is why I mentioned that I may have to hard code some of the data step. Thanksgiving, Fall Break, Winter Break, etc cannot be counted even though some of those days are weekdays.
Hi,
A combination of intck:
SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition
And this post (there are many others here on dates/holidays):
This is very helpful. One thing though: the notes regarding this code indicate that Sunday is counted as a weekday. Is that correct? I only want to count Mon - Fri.
wdvar=intck('weekday7w','01jan97'd,
'01feb97'd);
put wdvar;
data _null_;
wdvar=intck('weekday17w','08mar2015'd,
'10mar2015'd);
put wdvar;
run;
According to SAS functions, M-F is a weekday.
I had time to explore the links you provided. I am now on track. Thanks for answering this question.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.