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
Merging datasets by inner joinHi, I have to merge three datasets by matching IDs as shown in the picture below. This is doable in…
When I import csv.file, some variables are not recognizedWhen I import csv.file, some variables are not recognized (?) but appear in the first some cells lik…
test runHello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
xtreg fe versus areg robust errors?Hello! I apologize if some of the questions in this post seem simple, but this has to do with my the…
Expanding DatasetHi everyone, I am trying to expand a dataset that looks like this: Dataset A contract_id region_…
Subscribe to:
Post Comments (Atom)
0 Response to Sorting and reshaping: can't get the right order
Post a Comment