Hello,

I have been browsing manuals and forums but I have been stuck with this issue and hoping to get some advice. I managed to get frequency tables for 60 categorical variables into a Ms Word document using the code below in Stata 16.1. I end up with a Word document with 60 tables, each with three columns (Categories, Frequency, Percent) and the number of rows equivalent to the levels of the categorical variable plus one for the totals. However, I cannot figure out how to import the value labels for each variable rather than the numeric codes:

Code:
putdocx clear
            putdocx begin, pagesize(A4) font("Times New Roman", 11, black)
            putdocx paragraph, font("", 11) halign (right) 
            putdocx text (c(current_date)), bold    

            foreach varname of varlist {
                sum `varname'
                scalar num_`varname' = r(N)
                scalar mean_`varname' = r(mean)
                tab `varname', matcell(cell) matrow(row)
                matrix percent = (cell/r(N))*100
                matrix tab_`varname' = (row, cell, percent)
                matrix total = (.,r(N),100)
                matrix tab_`varname' = tab_`varname'\total
                local varlabel : variable label `varname'
                matrix colnames tab_`varname' = Categories Frequency Percent
                putdocx paragraph, font ("Times New Roman", 12, black) halign (left)
                putdocx text ("`varlabel'"), bold
                putdocx table oneway = matrix(tab_`varname'), colnames nformat(%9.2f)
            }
            putdocx save "Title", replace
I have tried adding lines:

Code:
    local valuelabel : value label `varname'
                matrix rownames tab_`varname' = "`valuelabel'"
                putdocx text ("`varlabel'"), bold
                putdocx table oneway = matrix(tab_`varname'), colnames rownames nformat(%9.2f)
            }
But this way I get tables with 4 columns, of which the first one has the variable label in all rows and the second one still has the numerical codes for each level. Any advice?

Many thanks,

Silvia