I am trying to do survival analysis with program participation data. Here is my data:
In order, the variables are a person identifier, month-date, indicator for program participation, tspell output variables (_seq, _spell, _end), and start and end dates for each spell.
My initial approach was the following:
But the FAQ for survival analysis with spell-type data (https://www.stata.com/support/faqs/statistics/stset-spell-type-data/) seems to suggest something like the following:
Output from neither approach looks correct.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long uniqueid float modate double program byte(_seq _spell _end) int(_start _enddate) 1 696 1 7 1 0 690 708 1 697 1 8 1 0 690 708 1 698 1 9 1 0 690 708 1 699 1 10 1 0 690 708 1 700 1 11 1 0 690 708 1 701 1 12 1 0 690 708 1 702 1 13 1 0 690 708 1 703 1 14 1 0 690 708 1 704 1 15 1 0 690 708 1 705 1 16 1 0 690 708 1 706 1 17 1 0 690 708 1 707 1 18 1 0 690 708 1 708 1 19 1 1 690 708 1 742 1 1 2 0 742 743 1 743 1 2 2 1 742 743 2 696 1 25 1 0 672 702 2 697 1 26 1 0 672 702 2 698 1 27 1 0 672 702 2 699 1 28 1 0 672 702 2 700 1 29 1 0 672 702 2 701 1 30 1 0 672 702 2 702 1 31 1 1 672 702 2 708 1 1 2 0 708 742 2 709 1 2 2 0 708 742 2 710 1 3 2 0 708 742 2 711 1 4 2 0 708 742 2 712 1 5 2 0 708 742 2 713 1 6 2 0 708 742 2 714 1 7 2 0 708 742 2 715 1 8 2 0 708 742 2 716 1 9 2 0 708 742 2 717 1 10 2 0 708 742 2 718 1 11 2 0 708 742 2 719 1 12 2 0 708 742 2 720 1 13 2 0 708 742 2 721 1 14 2 0 708 742 2 722 1 15 2 0 708 742 2 723 1 16 2 0 708 742 2 724 1 17 2 0 708 742 2 725 1 18 2 0 708 742 2 726 1 19 2 0 708 742 2 727 1 20 2 0 708 742 2 728 1 21 2 0 708 742 2 729 1 22 2 0 708 742 2 730 1 23 2 0 708 742 2 731 1 24 2 0 708 742 2 732 1 25 2 0 708 742 2 733 1 26 2 0 708 742 2 734 1 27 2 0 708 742 2 735 1 28 2 0 708 742 2 736 1 29 2 0 708 742 2 737 1 30 2 0 708 742 2 738 1 31 2 0 708 742 2 739 1 32 2 0 708 742 2 740 1 33 2 0 708 742 2 741 1 34 2 0 708 742 2 742 1 35 2 1 708 742 end format %tm modate format %tm _start format %tm _enddate
My initial approach was the following:
Code:
stset _seq, id(uniqueid) failure(_end) exit(time .)
Code:
stset _enddate, failure(_end) origin(_start) id(uniqueid) exit(time .)