I have data in long form that contains event occurences I have one row per event, and the length of the event in days is indicated by the variable "Duration." There are multiple types of events in the datasets; type is indicated in the EventType variable and the below dataex has two event types: OSS and DET (there are more event types but for simplicity I just included those 2). For each person, varname "ID", I am trying to create a dataset that has new variables with counts of occurences of each type of event, as well as new variables with the total duration of each event type. So, my question is, how do I create a dataset that has the below variables:
ID OSS_Count OSS_Duration DET_Count DET_Duration
where OSS_Count is the number of rows an ID had with EventType "OSS" and OSS_Duration is the sum of Duration that ID had for rows with EventType OSS, and so on for the other EventTypes?
Thanks in advance!
-Alyssa Beavers
ID OSS_Count OSS_Duration DET_Count DET_Duration
where OSS_Count is the number of rows an ID had with EventType "OSS" and OSS_Duration is the sum of Duration that ID had for rows with EventType OSS, and so on for the other EventTypes?
Thanks in advance!
-Alyssa Beavers
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long ID byte Duration str3 EventType 123456 3 "OSS" 123456 2 "OSS" 123457 1 "OSS" 123458 1 "OSS" 123459 1 "OSS" 123460 6 "OSS" 123460 1 "OSS" 123461 2 "DET" 123456 4 "DET" 123456 1 "DET" end
Comment