I have created the following summary table containing the mean, sd, min and max as well as the correlations for a range of variables in Stata. I have used putdocx to export the results to Word.
In Word, I am manually splitting the Table at the column Unemployment rate vertically to move the rest of the correlation table to the next page, add the first column again, so that the correlation table is readable when fit onto one page. Is there a way to automize this in putdocx? I have read the manual, but I only found that headerrow(1) option.
Code:
putdocx begin putdocx sectionbreak, landscape putdocx paragraph, style(Heading2) putdocx text ("Table 1: Correlation table for 1970-2019") pwcorr GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation, sig matrix sig = vech(r(sig))' table (result coleq) (colname), statistic(freq) statistic(mean GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation) statistic(sd GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation) statistic(min GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation) statistic(max GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation) command(corr=(vech(r(C))'): pwcorr GDPppp popsize electricityaccess GDPgrowth unemploymentrate inflation fdi trade grosssavings privatesectorcredit capitalformation) nformat(%5.2f mean sd) collect style cell result[corr], maximum(0.99, label(" - ")) nformat(%6.2f) halign(center) local stripe : colfullname sig foreach el of local stripe { if sig[1,"`el'"] < 0.05 { tokenize "`el'", parse(":") collect style cell result[corr]#coleq[`1']#colname[`3'], /// font(, bold) smcl(error) } } collect stars sig 0.01 "***" 0.05 "**" 0.1 "*", attach(corr) shownote collect layout (colname) (result[freq mean sd min max] coleq#result[corr]) collect style cell result, nformat(%8.2g) halign(center) collect style header result[corr], level(hide) collect label levels result sd "SD", modify collect label levels result min "Min.", modify collect label levels result max "Max.", modify collect label levels colname GDPppp "1. GDP" popsize "2. Population size" electricityaccess "3. Electricity access" GDPgrowth "4. GDP Growth" unemploymentrate "5. Unemployment rate" inflation "6. Inflation" fdi "7. Foreign direct investment" trade "8. Trade" grosssavings "9. Gross savings" privatesectorcredit "10. Private sector credit" capitalformation "11. Capital formation", modify collect label levels coleq GDPppp "1. GDP" popsize "2. Population size" electricityaccess "3. Electricity access" GDPgrowth "4. GDP Growth" unemploymentrate "5. Unemployment rate" inflation "6. Inflation" fdi "7. Foreign direct investment" trade "8. Trade" grosssavings "9. Gross savings" privatesectorcredit "10. Private sector credit" capitalformation "11. Capital formation", modify collect preview putdocx collect putdocx save Correlation, replace
Comment