Hello experts,

I have a dataset with 10,181 observations where each observation represents an individual held at a facility. Each element has information about when the individual was "booked into" (i.e., admitted) custody, when the person was "booked out" (i.e., released) from custody, and the facility where the individual was held. There are 113 unique facilities. The "book in" variable ranges from 09mar2012 to 01mar2018. The "book out" variable ranges from 18may2013 to 01jun2018. There is no missingness.

How do I compute the daily population for each facility? How do I count the number of individuals in custody at each facility for everyday from 09mar2012 to 01jun2018?

I have included a simple data example below. I am using Stata 15.1. Any help is great appreciated--thank you for your time.

Code:
*Example generated by -dataex-...to install: ssc install dataex
clear
input int(bookin bookout) long facility
19061 19541 75
19113 19536 36
19143 19661 49
19199 19675 72
19222 19670 36
19278 19766 57
19279 19556 36
19311 19666 85
19334 19542 49
19337 19612 15
19340 19682 34
19347 19606 87
19385 19517 33
19418 19535 57
19419 19661 30
19423 19606 36
19426 19600 1
19428 19536 36
19430 19677 72
19436 19561 112
19443 19666 85
19444 19694 55
19444 19564 112
19447 19675 74
19449 19575 49
end

format %tdnn/dd/CCYY bookin
format %tdnn/dd/CCYY bookout
label values facility facility_destrung
label def facility_destrung 1 "FAC1", modify
label def facility_destrung 15 "FAC2", modify
label def facility_destrung 30 "FAC3", modify
label def facility_destrung 33 "FAC4", modify
label def facility_destrung 34 "FAC5", modify
label def facility_destrung 36 "FAC6", modify
label def facility_destrung 49 "FAC7", modify
label def facility_destrung 55 "FAC7", modify
label def facility_destrung 57 "FAC8", modify
label def facility_destrung 72 "FAC9", modify
label def facility_destrung 74 "FAC10", modify
label def facility_destrung 75 "FAC11", modify
label def facility_destrung 85 "FAC12", modify
label def facility_destrung 87 "FAC13", modify
label def facility_destrung 112 "FAC14", modify
label var bookin "Book-in Date"
label var bookout "Book-out Date"
label var facility "Facility Number"