Hi there,
I would like to assess changes in outcomes (PHQ-4 scores) from baseline to last observation, baseline to 3 months, and baseline to 6 months, where individuals in the dataset report these measures at different timepoints.
I used the following code to calculate the change from baseline to last observation. How can I adapt this to calculate the change from baseline to 3 months and baseline to 6 months, if possible? Thank you very much for your help, much appreciated.
gen missingPHQ4_crfl = missing(PHQ4_cr)
bysort missingPHQ4_crfl pid (date) : gen change_PHQ4_crfl = PHQ4_cr[_N] - PHQ4_cr[1]
bysort pid (change_PHQ4_crfl) : replace change_PHQ4_crfl = change_PHQ4_crfl[1]
su change_PHQ4_crfl
I would like to assess changes in outcomes (PHQ-4 scores) from baseline to last observation, baseline to 3 months, and baseline to 6 months, where individuals in the dataset report these measures at different timepoints.
I used the following code to calculate the change from baseline to last observation. How can I adapt this to calculate the change from baseline to 3 months and baseline to 6 months, if possible? Thank you very much for your help, much appreciated.
gen missingPHQ4_crfl = missing(PHQ4_cr)
bysort missingPHQ4_crfl pid (date) : gen change_PHQ4_crfl = PHQ4_cr[_N] - PHQ4_cr[1]
bysort pid (change_PHQ4_crfl) : replace change_PHQ4_crfl = change_PHQ4_crfl[1]
su change_PHQ4_crfl
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pid float(date PHQ4_cr) 2640739 23362 8 2601672 23712 4 2783799 23559 8 2369902 23658 3 2589963 23491 10 2597833 23569 6 1897982 23163 5 2369941 23042 2 2796273 23931 0 2788566 23630 9 2608931 23313 2 2934668 23848 4 2807186 23607 7 2684888 23653 10 2711011 23479 4 2831792 23656 4 2523708 23408 3 2515519 23109 3 2589089 23284 8 2428397 23628 4 2792814 23924 6 2432081 22993 7 2489312 23088 12 2524164 23184 0 2524168 23217 3 2137023 22980 9 2817119 23622 6 2200501 23307 9 2671054 23712 10 2785280 23560 5 2509050 23116 5 2793044 23573 4 2660809 23401 1 2863740 23716 1 2726795 23594 2 2855672 23698 5 2383006 23541 7 2789558 23568 7 2167655 23209 8 2876408 23798 4 2655408 23389 8 2828400 23644 12 2588133 23269 10 2870328 23747 2 2669539 23611 8 2936921 23857 4 2638962 23628 7 2610403 23311 10 2311386 23565 4 2675651 23499 7 end format %td date

Comment