Dear Stata users,
I have data in long format with dates of specific events for each unique identifier. The goal is to try and calculate duration between some events. Below is an example of data
* Example generated by -dataex-. For more info, type help dataex
clear
input float(ID step) int date
101 100 20577
101 200 20682
101 300 20759
101 400 20767
101 700 21947
102 200 20361
102 300 20445
102 400 20577
102 500 20682
102 700 20759
103 100 20767
103 200 21945
103 300 21054
103 400 21059
103 500 21101
103 600 21131
103 700 21145
104 100 21166
104 200 21549
104 300 21153
104 400 21157
104 500 21159
104 600 21161
104 700 21165
105 100 21165
105 300 21585
105 400 21527
105 500 21528
105 600 21529
105 700 21530
end
format %tdnn/dd/CCYY date
[/CODE]
ID is the unique identifier, Step is the event and date is the date when the event occurred.
I would like for example to calculate the duration between step 100 - 500, 200 - 700.
Notably, not all unique IDs have all steps. There's a possibility of some IDs not having some steps.
Thanks in advance!
Related Posts with Calculating durations by ID
Interpretation OLS residualHi, I don't know how interpret the OLS of residuals. There is my code : Code: *model 4 CD regress …
Creating two groups based on a continuous variable OK, for the sake of transparency, this is not a work issue... I am a clinician-scientist and just c…
Is it okay to use lagged variable as my instrument when using control function?Hello, I am having a hard time dealing with endogeneity problems in my data, and recently I found a …
skewed GARCHHello Statalist, I'm a Ph.D student and I'm currently working on my project, basically I'm trying to…
Failure Rate using 'strate' at multiple exit pointsHi Everone, I am stuck on a problem. I want to graph the failure rate at varying time point viz. 1,…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating durations by ID
Post a Comment