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
Help with SEM in StataHello! I am trying to run SEM on the model I have attached. I can't seem to figure out why it runs p…
Mata matrix to variables using st_storeI've created a matrix of Halton Draws in Mata, and I'd like to use each column of the matrix as a va…
Drop before calculating a meanHey guys ! If I have a dummy with 1 and zero wether a trade is a buy or sell and want to find out wh…
Initial period variablesHi all, What is the best model to use when one has initial period variables such as log of initial …
Propensity Score Matching with multiple and continous treatmentsHello, I want to make a propensity score matching using four different treatments, which are all me…
Subscribe to:
Post Comments (Atom)
0 Response to Calculating durations by ID
Post a Comment