Hello all: This has been irking me for a while but I cannot get it to work. I need the row variable labels (not each of their levels) bolded in the final word table I am create with the dtable.
Would like some help with getting the code right. I can get until collect style cell [rowheader] but it is not working as I want it. Below I would like "t2" and "Baseline parms. [IQR]" to be in bold.
Would like some help with getting the code right. I can get until collect style cell [rowheader] but it is not working as I want it. Below I would like "t2" and "Baseline parms. [IQR]" to be in bold.
Code:
sysuse auto, clear
collect clear
putdocx clear
**# Table 1
*----------------------
gen turnbinary = turn > 35
lab def tlab 0 "Low Turn" 1 "High Turn"
lab val turnbinary tlab
local binvars "i.turnbinary"
dtable c.weight `binvars', by(foreign, tests nototals nomissing) column(by(hide)) ///
continuous(weight length mpg, statistics(p50 iqi)) ///
define(iqi = min max, delimiter("-")) ///
sformat("[%s]" iqi) ///
nformat(%5.0f iqi) ///
nformat(%3.1f p50) ///
factor(`binvars', statistics( fvfreq fvpercent) test(pearson) font( arial,nobold)) ///
sample(Sample, statistic(frequency percent) place(seplabels)) sformat("N=%s" frequency) ///
// Add a tag to nest contvars into a group under Baseline labs
*------------------------------------------------------------
collect addtags vargrp[Baseline parms. [IQR]], fortags(var[length mpg])
// Bold column headers and stack
*-------------------------------
collect style cell cell_type[column-header], font(arial, bold)
collect style row stack, truncate(head)
collect style cell cell_type[row-header]#turnbinary, font(arial, bold)
// Final layout & export
*-----------------------
collect layout (vargrp#var var[`binvars']) (foreign#result#_dtable_sample_dim)
collect preview
collect style putdocx, layout(autofitcontents) ///
collect export "./test.docx", replace
Comment