Hi everybody, I'm so sorry to bother you.
I have the following dataset:
ID ammission_date dismission_date
1 07sep2019 09sep2019
1 15 sep2019 28sep2019
2 9mar2020 10mar2020
3 6june2020 8june2020
3 8may2020 10 may2020
3 1jan2020 21jan2020
...
I need to calculate if the distance between first dismission date and second ammission date (and between the second dismission date and the third ammission date and so on) is <=7 for repeted observations.
I thought of first sorting the ammission dates, then the ID (which in my dataset is not sorted) and then to reshape wide in order to calculate the distance by row. This doesn't work properly because the new vars I get with the reshape wide are not sorted (ammission_date1 could be further thant ammission_date2). Have you any idea of how can I do? Thank you a lot!
Martina
Related Posts with Sorting and reshaping: can't get the right order
range function generating over 400 missing valuesHello, I am trying to make a Stata variable that stores 20 numbers between 0 and 1. I am using the …
Is it possible to use the Stata-python integration module inside of foreach Stata loop?Hello, I am trying to execute the code below and it is giving me an error, mainly because the Stata…
stata command unrecognized r(199) errorHello, I am trying to run the Stata code below, and everything runs except at the very end I am gett…
Wrong coefficient in a fixed effects panel regressionHello, I'm trying to regress the impact that fiscal rules might have on the Primary Balance of a Co…
Fixed effects (in Accelerated Failure Time Survival Model), Cross-sectionalHi, For my research I am examining private equity strategies and their subsequent exit-types. My da…
Subscribe to:
Post Comments (Atom)
0 Response to Sorting and reshaping: can't get the right order
Post a Comment