I am trying to write a wrapper placed in a do file to include for survival analysis. There is date of diagnosis (dodx), date of transplant (dotsp1), docensor (censor date). I want to generate three different analysis time options and call each as relevant. I am using version 19.0.
I am unable to see why the syntax is not correct, even from the trace. Happy to share a dataex if that would help.
Result with trace on:
The program sits inside a utils.do file (as invoked below) that I -qui do- as below and not in an ado file:
I am unable to see why the syntax is not correct, even from the trace. Happy to share a dataex if that would help.
Code:
cap program drop stset_custom program define stset_custom // note: no [ ] around the options here syntax , mode(string) [months(real)] // 1. Determine default months if not supplied if ("`months'" == "") { if "`mode'" == "dx_cens" local months 24 else if "`mode'" == "tx_cens" local months 60 else if "`mode'" == "dx_txcens" local months 24 else { di as error "Unknown mode `mode'. Allowed: dx_cens, tx_cens, dx_txcens" exit 198 } } // 2. Echo the program statements di as txt "// stset_custom: mode=`mode', censor at `months' months" // 3. Dispatch to the right stset call if "`mode'" == "dx_cens" { stset docens, fail(dead) /// origin(time dodx) enter(time dodx) /// exit(time dodx + `months' * 30.455) /// scale(30.455) id(obs) } else if "`mode'" == "tx_cens" { stset docens, fail(dead) /// origin(time dotsp1) enter(time dotsp1) /// exit(time dotsp1 + `months' * 30.455) /// scale(30.455) id(obs) } else if "`mode'" == "dx_txcens" { tempvar exit_time gen double `exit_time' = min(dotsp1, dodx + `months' * 30.455) format `exit_time' %td stset docens, fail(dead) /// origin(time dodx) enter(time dodx) /// exit(time `exit_time') /// scale(30.455) id(obs) drop `exit_time' } end
Code:
set trace on st_set, mode(dx_cens) months(24) . st_set, mode("dx_cens") months(24) ------------------------------------------------------------- begin st_set --- - version 6, missing - if ("`1'"=="clear") { = if (","=="clear") { Clear exit } - if ("`1'" != "set") { exit 198 } = if ("," != "set") { exit 198 } --------------------------------------------------------------- end st_set --- r(198);
The program sits inside a utils.do file (as invoked below) that I -qui do- as below and not in an ado file:
Code:
*--------------------PROJECT INITIALIZATION SCRIPT-----------------------------* local prfolder prj_sv include DIRECTORY_INITIALIZATION_sv.DOH, adopath *----------------------------Chunker-------------------------------------------* ************************************************************************* *Impact of Tazy score within TP53 mutated high-grade myeloid neoplasm ************************************************************************* // Program: p53_descr_docs.do // Task : Uses an01-merged.dta and the long file with all TP53 mutations per case. // Outputs: Descriptive writeup for the paper // Project: TP53 mutations in myeloid and outcome // Author : GV \date: 2023-11-02 di "`c(current_date)'" // ==================================================================== **# Data subsetting for study // ==================================================================== use "`prfold'/dtafiles//an01-merged.dta" * Check totals isid mrn // Change dir to includes folder *------------------------------- cd "`pwork'" qui include unicoder qui do utils // Include data subsetting, ST setting for OS24 *---------------------------------------------- qui include"`prdo'/selects//p53select.doh" // Include all figure call and style macros *------------------------------------------ qui include "`prdo'/selects//includefig.doh" qui include "`prdo'/selects//pdocstyles.doh" // Figure calls
Comment