Hi.
I have a dataset where I have registered observations on specific dates within a different periods from start_date to end_date.
I want to generate a variable that counts "on what day the event occurred" within my periods.
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id long event float(date_of_event start_date end_date)
11 1 1.870004e+12 1.867075e+12 1.870589e+12
11 3 1.8681838e+12 1.867075e+12 1.870589e+12
11 2 1.869392e+12 1.867075e+12 1.870589e+12
13 2 1.8693916e+12 1.867075e+12 1.870589e+12
13 1 1.869403e+12 1.867075e+12 1.870589e+12
16 2 1.870447e+12 1.867075e+12 1.870589e+12
16 1 1.8692985e+12 1.867075e+12 1.870589e+12
17 2 1.870551e+12 1.867075e+12 1.870589e+12
17 2 1.8705503e+12 1.867075e+12 1.870589e+12
19 2 1.870559e+12 1.867075e+12 1.870589e+12
end
format %tc date_of_event
format %tc start_date
format %tc end_date
In this example there is only one period but my dataset contains several different periods.
So in order to compare timing of events across different periods I need a variable that counts the first day in the period as days 1, the second day as day 2, etc.
Time is not important (for this) and does not need to be accounted for in the new variable.
Hope you can help me.
Kind regards
Related Posts with Variable assigning number to dates within periods
Computing predicted probabilities of uptake in a discrete choice experimentDear Statalist, I conduct a discrete choice experiment. I have seven attributes with 6, 4, 3, 3, 3,…
R Class ProgramI use a rclass program to obtain significance stars after running two regressions. When I run the fi…
Why there is missing t-test information for one controlling variable after using PSM and ptest?Array Dear friends, I applied PSM using below command, psmatch2 treat x1 x2 , out(Y) logit ate neig…
Panel ARDL Huasman test>>>"invalid new variable name"Dear Stata Team, I am running a Panel ARDL model but want to choose between "mg" or "pmg" using the …
calculate percentageHello, everyone, in my panel data I would like to calculate the percentage of restatements during th…
Subscribe to:
Post Comments (Atom)
0 Response to Variable assigning number to dates within periods
Post a Comment