BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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):

View solution in original post

7 REPLIES 7
Ksharp
Super User

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

GreggB
Pyrite | Level 9

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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):

GreggB
Pyrite | Level 9

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;

Ksharp
Super User

data _null_;

wdvar=intck('weekday17w','08mar2015'd,

  '10mar2015'd);

put wdvar;

run;

Reeza
Super User

According to SAS functions, M-F is a weekday.

GreggB
Pyrite | Level 9

I had time to explore the links you provided.  I am now on track. Thanks for answering this question.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1336 views
  • 0 likes
  • 4 in conversation