May you assist since I am not very familiar with lag functions. I am working with longitudinal data (multiple records per person) and I would like to create a new variable "diff" based on the previous record. So "within personid" : gen (date _episode - date_episode "of previous record") = diff. to look like this
personid | date_episode | diff |
1 | 2/05/2020 | 0 |
1 | 5/09/2020 | 126 |
1 | 8/10/2020 | 33 |
1 | 9/11/2020 | 32 |
0 Response to Lag function using dates
Post a Comment