Hello all:
I decided to graduate myself from using only include files to creating a program for a standard display of Cox model HR and 95% CIs for a single dummy indicator to be used in putdocx statements. I will change the di command below to a putdocx down the line in my paper write up.
While the last scalar is evaluating correctly within the program based on my set trace on, the scalar calls and local macros defined inside the program are not surviving outside the program. I was blindly changing around quotes, compound double quotes and assignment operators in that last scalar call without success. I have chosen to use the stan3 data set so it is fully reproducible.
What this evaluates to in the display:
I decided to graduate myself from using only include files to creating a program for a standard display of Cox model HR and 95% CIs for a single dummy indicator to be used in putdocx statements. I will change the di command below to a putdocx down the line in my paper write up.
While the last scalar is evaluating correctly within the program based on my set trace on, the scalar calls and local macros defined inside the program are not surviving outside the program. I was blindly changing around quotes, compound double quotes and assignment operators in that last scalar call without success. I have chosen to use the stan3 data set so it is fully reproducible.
Code:
webuse stan3, clear // Program coxer below------------------------- version 18.0 cap program drop coxer cap drop scalar callhr program define coxer, rclass syntax varlist(numeric min=0 max=1) [if] marksample touse stcox `varlist' if(`touse') tempname a mat `a' = r(table) matrix list `a' // Gather HR, 95% and pvalue *-------------------------- local b = string(`a'[1,1], "%09.1fc") local l = string(`a'[5,1], "%09.1fc") local u = string(`a'[6,1], "%09.1fc") local p = `a'[4,1] local n = e(N) // Fix p-value formats *--------------------- if `p'>=0.056 { local pvalue = "= " + string(`p', "%03.2f") } if `p'>=0.044 & `p'<0.056 { local pvalue = "= " + string(`p', "%05.4f") } if `p' <0.044 { local pvalue = "= " + string(`p', "%04.3f") } if `p' <0.001 { local pvalue "< 0.001" } if `p' <0.0001 { local pvalue "< 0.0001" } set trace on // Create display text for the HR *--------------------------------- scalar callhr = "(HR = `b'; 95% CI: [`l', `u'];P = `pvalue')" end // Test the program *------------------ coxer transplant di "This is the effect of transplant callhr and checking `b'" di "`b'"
Code:
- scalar callhr = "(HR = `b'; 95% CI: [`l', `u'];P = `pvalue')" = scalar callhr = "(HR = 0.3; 95% CI: [0.2, 0.4];P = < 0.0001)" . di "This is effect of transplant callhr and checking `b'" This is effect of transplant callhr and checking . di "`b'"
Comment