Just read a paper by Golay, P., et al., "Identifying patterns in psychiatric hospital stays with statistical methods: towards a typology of post-deinstitutionalization hospitalization trajectories". Social Psychiatry and Psychiatric Epidemiology, 2019. In the paper they claimed that "For each patient, hospitalizations were aggregated into a string of 1095 digits with digits 0 (not in hospital) or 1 (in hospital) for every day over a 3-year period. Each state sequence started with the first day at hospital and included the next 3 years of records." I am not sure how this "aggregation", or data transformation can be done in STATA.
The following is a sample hospital record data. There are 4 patients with 12 records, with each record stands for one inpatient stay. In order to do the sequence analysis on these patients hospital stay pattern for 1 year after their first admission, I need to generate a variable that have 365 digits, with each digit representing whether the patient was in hospital in each of the 365 days after the first admission (if yes, digit 1; if not, digit 0). If a patient stayed in hospital for 3 days and then came back 2 days later, the variable should be like: 1110011...
I read the Help file of the -sq- package, but I don't know how command like -sqset- can put together data with ranges, like dates. Therefore it would be great if someone can find a way to generate this "sequence" variable out of hospitalization data. Thanks very much!
Here is the sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte patientid float(indate outdate) 1 19083 19092 1 19111 19119 1 19142 19146 1 19170 19174 1 19198 19214 1 19215 19228 2 19234 19248 2 19430 19474 3 19193 19194 4 19060 19075 4 19339 19357 4 19541 19558 end format %td indate format %td outdate
Regards,
Ginny Han
0 Response to How to arrange hospitalization data for sequence analysis
Post a Comment