Hello all,
So I have a dataset of clients with one or more social service episodes and within each episode there can be one or more events. Each event has a begin date and an end date. I want to make a wide dataset so that there is a column for each day for a given time period, for example, calendar year 2019. And for each event I want to flag the days that occur during the given time period. There is more that I want to do but this would be a great start.
Here is an example data set:
data have; infile datalines;
input Client_ID $ Episode_ID $ Event_ID $ Begin_Date :date9. End_Date :date9. Event_Plcmnt $;
format Begin_date End_Date date9.;
datalines;
001 001 001 20MAY2019 23MAY2019 GC
001 001 002 22MAY2019 23MAY2019 OTHER
001 001 003 23MAY2019 23OCT2019 GC
001 001 004 29JUN2019 30JUN2019 OTHER
001 001 006 14JUL2019 15JUL2019 OTHER
001 001 007 19JUL2019 23JUL2019 OTHER
001 001 005 25JUL2019 08AUG2019 OTHER
001 001 008 09AUG2019 10AUG2019 OTHER
001 001 009 11AUG2019 12AUG2019 OTHER
001 002 010 01NOV2019 16APR2020 URC
And here is what I want it to look like:
Client_ID
Episode_ID
Event_ID
Begin_Date
End_Date
Event_Plcmnt
01JAN2019
02JAN2019
...
20MAY2019
21MAY2019
22MAY2019
23MAY2019
24MAY2019
25MAY2019
...
30DEC2019
31DEC2019
001
001
001
20May2019
23May2019
GC
...
1
1
1
1
...
001
001
002
22May2019
23May2019
Other
...
1
1
...
001
001
003
23May2019
23Oct2019
GC
...
1
1
1
...
001
001
004
29Jun2019
30Jun2019
Other
...
...
001
001
005
14Jul2019
15Jul2019
Other
...
...
001
001
006
19Jul2019
23Jul2019
Other
...
...
001
001
007
25Jul2019
8Aug2019
Other
...
...
001
001
008
09Aug2019
10Aug2019
Other
...
...
001
001
009
11Aug2019
12Aug2019
Other
...
...
001
002
010
01Nov2019
16Apr2020
URC
...
...
1
1
I've truncated, of course, to save space. Also, there are a number of other columns that I did not include in the sample dataset that I would need to carry over.
Let me know what you all think.
Best,
Marc
... View more