Hello forum,
I have two time-series data of students that I need to merge. One contains the number of students’ misbehavior per day (BehaviorData-daily) and the other contains the time period and location where students were housed (HousedData). The problem with the HousedData is that only has time periods, not daily data (see below). I need to assign the misbehavior count to the corresponding date period. So if in my example below if the student misbehaved on April 9, it should be next to the April 7 to Apr 10.
I guess there are two options here. One would be to generate daily observation of my HousedData and then merge. Another option would be to work first using the behavior data, and assign the time range (ex April 7 to Apr 10) to the specific date of the misbehavior. How can I do this using my strategies? Or perhaps there are another more efficient ways to do this? I would appreciate any help.
I have two time-series data of students that I need to merge. One contains the number of students’ misbehavior per day (BehaviorData-daily) and the other contains the time period and location where students were housed (HousedData). The problem with the HousedData is that only has time periods, not daily data (see below). I need to assign the misbehavior count to the corresponding date period. So if in my example below if the student misbehaved on April 9, it should be next to the April 7 to Apr 10.
1131600265 | 4-Apr-16 | 6-Apr-16 |
1131600265 | 7-Apr-16 | 10-Apr-16 |
1131600265 | 11-Apr-16 | 13-Apr-16 |
I guess there are two options here. One would be to generate daily observation of my HousedData and then merge. Another option would be to work first using the behavior data, and assign the time range (ex April 7 to Apr 10) to the specific date of the misbehavior. How can I do this using my strategies? Or perhaps there are another more efficient ways to do this? I would appreciate any help.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long ID int(startdt enddt) str2 room byte Ineed . . . "" . 1131600265 20548 20550 "a1" 6 1131600265 20551 20554 "a1" 2 1131600265 20555 20557 "a2" . 1131600265 20558 20561 "a2" . 1131600265 20562 20564 "a2" . 1131600473 20583 20585 "a2" . 1131600473 20586 20589 "a1" . 1131600473 20590 20592 "a1" 1 1131600473 20593 20596 "a1" 2 1131600473 20597 20599 "a2" . 1131600265 20548 20550 "a1" . 1131600265 20551 20554 "a2" . 1131600265 20555 20557 "a3" . 1131600265 20558 20561 "a4" . 1131600265 20562 20564 "a5" 1 end format %tddd-Mon-YY startdt format %tddd-Mon-YY enddt
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long ID int behavior byte count . . . 1131600265 20548 3 1131600265 20549 1 1131600265 20550 2 1131600265 20551 1 1131600265 20552 1 1131600473 20590 1 1131600473 20593 1 1131600473 20594 1 1131600265 20563 1 end format %tdnn/dd/CCYY behavior
Comment