|
Table
Output: rtf (for use in a Word document)
Twoway table where the output can be loaded on a Word document. ie After running
the code below open the file (mydoc3.rtf) into Word.
Requires: rtfutil
To download rtfutil type the following on the Stata command line:
ssc install rtfutil
To run the example: copy the following into a do file and run
use http://www.stata-press.com/data/r11/nlswork.dta, clear
collapse (sum) hours (mean) worked=hours (mean) union_member=union ,by(year) fast
format worked %8.2f
format union_member %8.2f
sdecode hours, replace prefix("\qr{") suffix("}")
sdecode worked, replace prefix("\qr{") suffix("}")
sdecode union_member, replace prefix("\qr{") suffix("}")
sdecode year, replace prefix("\qr{") suffix("}")
order year hours worked union_member
tempname handle3
rtfopen `handle3' using "mydoc3.rtf", template(fnmono1) replace
capture noisily {
file write `handle3' ///
"{\pard\qr{\b Table of hours and union membership years 1968-1988}\par}" _n
rtfrstyle year hours worked union_member, tdadd("\trqr") ///
cdadd("\clbrdrt\brdrw20\brdrtriple\clbrdrb\brdrw20\brdrtriple") ///
cwidths(2160 1440 1440 1440) local(B)
rtfrstyle year hours worked union_member, tdadd("\trqr") ///
cwidths(2160 1440 1440 1440) local(b d e )
listtab year hours worked union_member, handle(`handle3') ///
begin("`b'") delim("`d'") end("`e'") ///
head("`B'\ql{\i The Year}`d'\qr{\i Mean hours worked }`d'" ///
"\qr{\i Total hours Worked by Participants}`d'" ///
"\qr{\i Percentage Union Membership }`e'")
}
rtfclose `handle3'
|