/* menu intervace into ltable Based on ssa1 - Actuarial or Life Table Analysis of Time-to-Event Data Henry Krakauer and John Stewart, HCFA Modified Fri May 3 08:45:09 PDT 1991 by wwg */ set ado 15 program define ltablem version 2.1 mac def _tl1 "ltable: life-table analysis of time-to-event data" mac def _tl2 " (Press Break and Enter to abort)" mac def _stl "Specification of request:" if _N!=0 { mac def _dsnl "%S_FN" if "%_dsnl"=="" { mac def _dsnl "(current)" } } while _N==0 { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name:" _request(_dsn) ; #delimit cr mac def dsnl "%_dsn" capture use %_dsn, clear } while "%_t"=="" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name: " in wh "%_dsnl" _n in gr _col(17) "time-to-event variable:" _request(_t) ; #delimit cr capture confirm variable %_t if _rc~=0 { macro define _t } } while "%_d"=="" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name: " in wh "%_dsnl" _n in gr _col(17) "time-to-event variable: " in wh "%_t" _n in gr _col(27) "event marker:" _request(_d) ; #delimit cr capture confirm variable %_d if _rc~=0 { macro define _d } } while "%_unit"=="" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name: " in wh "%_dsnl" _n in gr _col(17) "time-to-event variable: " in wh "%_t" _n in gr _col(27) "event marker: " in wh "%_d" _n in gr _col( 8) "time unit (day/week/month/year):" _request(_unit) ; #delimit cr if "%_unit"!="day" & "%_unit"!="week" & "%_unit"!="month" /* */ & "%_unit"!="year" { mac def _unit } } mac def _g 1 while "%_g"=="1" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name: " in wh "%_dsnl" _n in gr _col(17) "time-to-event variable: " in wh "%_t" _n in gr _col(27) "event marker: " in wh "%_d" _n in gr _col( 8) "time unit (day/week/month/year): " in wh "%_unit" _n in gr _col( 5) "grouping variable (enter for none):" _request(_g) ; #delimit cr if "%_g"!="" { capture confirm var %_g if _rc { mac def _g 1 } } } if "%_g"!="" { mac def _by "by(%_g)" } while substr("%_answ",1,1)!="y" & substr("%_answ",1,1) !="n" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) _col(26) "data set name: " in wh "%_dsnl" _n in gr _col(17) "time-to-event variable: " in wh "%_t" _n in gr _col(27) "event marker: " in wh "%_d" _n in gr _col( 8) "time unit (day/week/month/year): " in wh "%_unit" _n in gr _col( 5) "grouping variable (enter for none): " in wh "%_g" _n in gr _col( 1) "do you wish a graph as well as a table?" _request(_answ) ; #delimit cr } if substr("%_answ",1,1)=="y" { mac def _graph graph } mac def _answ while substr("%_answ",1,1)!="y" & substr("%_answ",1,1)!="n" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n ; di in gr "The default time intervals (in days) are:" _n in ye " [0, 7) [15,30) [60, 90) [180,360) [540,720)" _n " [7,15) [30,60) [90,180) [360,540) [720,inf)" _n in gr "where [a,b) means the interval a <= t < b. Graphically, the intervals are:" _n(2) "!---+---+---+---------+" _dup(16) "-" "+" _dup(36) "-" "+->" _n "0 7 15 30 60" _skip(15) "90" _skip(35) "180" _n(2) ">+" _dup(74) "-" "+->" _n "180" _skip(72) "360" _n(2) ">+" _dup(74) "-" "+->" _n "360" _skip(72) "540" _n(2) ">+" _dup(74) "-" "+->" _n "540" _skip(72) "620" _n(2) "Do you wish to use these intervals? (y/n) " _request(_answ) ; #delimit cr } if "%_answ"=="n" { mac def _stl "Starting values entered so far:" mac def _intv 0 mac def _answ 0 while "%_answ"!="" { clrscrn #delimit ; di _n in ye "%_tl1" _n in gr "%_tl2" _n(2) "%_stl" _n(2) in ye _col(10) "%_intv" in gr _n(2) _col(10) "Specify starting value or next interval or press enter" _n "to quit entering values: " _request(_new) ; #delimit cr capture confirm number %_new if _rc==0 { if %_new>%_answ { mac def _intv "%_intv, %_new" } mac def _answ "%_new" } else if "%_new"=="" { mac def _answ } } mac def _intv "int(%_intv)" } clrscrn #delimit ; di in gr _n(2) "I will now issue the " in wh "ltable" in gr " command:" _n(2) in wh ". ltable %_t %_d, %_by %_graph %_intv units(%_unit)" ; #delimit cr ltable %_t %_d, %_by %_graph %_intv units(%_unit) end exit