Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: Output regression table with significance at some level indicate in bold font
From
"Andreas Peichl" <[email protected]>
To
<[email protected]>
Subject
st: RE: Output regression table with significance at some level indicate in bold font
Date
Thu, 9 Dec 2010 17:35:10 +0100
Dear Statalisters,
I've asked a question about highlighting the significant results in bold (ot
italics) after -estab- (see below). I was asked whether I found a solution.
I did it manually - and so far it heavily depends to the exact layout of my
table. Maybe it is helpful for someone. Any comments and suggestions are of
course welcome.
Cheers,
Andreas
(the full code is below, I start with some comments on some elements):
The code works as follows:
file open original using results/`tab'.tex, read text
file open new using results/`tab'_bold.tex, write replace
local linenum = 0
file read original line
while r(eof)==0 {
you read in the tex table from esttab
at the end, it will be written to another file:
file write new `"`macval(newline)'"' _n
file read original line
}
file close original
file close new
in between is the manipulation of each line using tex codes and regular
expressions.
e.g.:
if
regexm("`w`w''","^(.*)\sym{.*}&$") == 1 { //.* --> bold for 3 stars
if `CONSline' == 0 local to
= "\textbf{" + regexs(1) +"}&"
else if `CONSline' == 1 {
local expres =
regexs(1)
local expres :
subinstr local expres "\" "" , all
local to =
"\textbf{`expres'}&"
if
regexm("`expres'","^(.*)\.[0-9][0-9][0-9]$") == 1 local to = "\textbf{" +
regexs(1) +"}&"
}
local newword : subinstr
local w`w' "`w`w''" "`to'", all
local newword : subinstr
local newword "\}&" "}&", all
} // if
This searches for anything that end with "\sym{.*}&" In the tex code and
replace it with \textbf{ anything }
At the end, I define a macro newline which will then be written to the file:
local newline "`newline'`newword' "
mac shift
} // w / while
I hope this helps.
Cheers,
Andreas
Here is the full code:
cap file close _all
file open original using results/`tab'.tex, read text
file open new using results/`tab'_bold.tex, write replace
local linenum = 0
file read original line
while r(eof)==0 {
local linenum = `linenum' + 1
*display %4.0f `linenum' _asis `" `macval(line)'"'
*** local lclname [=exp | :extended_fcn |
[`]"[string]"['] ]
local oldline `"`macval(line)'"'
*** word count / word # of
*local words : word count "`oldline' "
tokenize "`oldline'"
local newline ""
local w 0
while "`1'" !="" {
local w= `w' + 1
local w`w' `1'
if `w' ==1 {
local w`w' : subinstr local w`w'
"BVmX\_" "", all
local w`w' : subinstr local w`w'
"u\_Vm" "Unobserved", all
if "`w`w''" == "Constant" local
CONSline = 1
else local CONSline = 0
} // if
*** subinstr local mname "from" "to", all
word
local newword "`w`w''" //
`"`macval(oldline)'"'
if `linenum'>=7 { // lines 1-6 are headers
necessary prob with mutlicolumn line; be careful if using different esstab
options !!!
if
regexm("`w`w''","^(.*)\sym{.*}&$") == 1 { //.* --> bold for 3 stars
if `CONSline' == 0 local to
= "\textbf{" + regexs(1) +"}&"
else if `CONSline' == 1 {
local expres =
regexs(1)
local expres :
subinstr local expres "\" "" , all
local to =
"\textbf{`expres'}&"
if
regexm("`expres'","^(.*)\.[0-9][0-9][0-9]$") == 1 local to = "\textbf{" +
regexs(1) +"}&"
}
local newword : subinstr
local w`w' "`w`w''" "`to'", all
local newword : subinstr
local newword "\}&" "}&", all
} // if
if
regexm("`w`w''","^(.*)\sym{.*}\\") == 1 { // end of line 3 stars
if `CONSline' == 0 local to
= "\textbf{" + regexs(1) +"}\\"
else if `CONSline' == 1 {
local expres =
regexs(1)
local expres :
subinstr local expres "\" "" , all
local to =
"\textbf{`expres'}\\"
if
regexm("`expres'","^(.*)\.[0-9][0-9][0-9]$") == 1 local to = "\textbf{" +
regexs(1) +"}\\"
}
local newword : subinstr
local w`w' "`w`w''" "`to'", all
local newword : subinstr
local newword "\}\\" "}\\", all
} // if
if
regexm("`w`w''","^(.*)\sym{\*\*}$") == 1 { //.* --> bold italics for 2
stars
if `CONSline' == 0 local to
= "\textbf{\emph{" + regexs(1) +"}}"
else if `CONSline' == 1 {
local expres =
regexs(1)
local expres :
subinstr local expres "\" "" , all
local to =
"\textbf{\emph{`expres'}}"
if
regexm("`expres'","^(.*)\.[0-9][0-9][0-9]$") == 1 local to =
"\textbf{\emph{" + regexs(1) +"}}"
}
local newword : subinstr
local w`w' "`w`w''" "`to'", all
local newword : subinstr
local newword "\}}" "}}", all
} // if
if regexm("`w`w''","^(.*)\sym{\*}$")
== 1 { //.* --> bold for 1 stars
if `CONSline' == 0 local to
= "\emph{" + regexs(1) +"}"
else if `CONSline' == 1 {
local expres =
regexs(1)
local expres :
subinstr local expres "\" "" , all
local to =
"\emph{`expres'}"
if
regexm("`expres'","^(.*)\.[0-9][0-9][0-9]$") == 1 local to = "\emph{" +
regexs(1) +"}"
}
local newword : subinstr
local w`w' "`w`w''" "`to'", all
local newword : subinstr
local newword "\}" "}", all
} // if
local newword : subinstr local
newword "\sym{***}" "\textbf{bold}", all
local newword : subinstr local
newword "\textbf{}" "\textbf{bold}", all
local newword : subinstr local
newword "\textbf{\emph{}}" "\textbf{\emph{bold italics}}", all
local newword : subinstr local
newword "\emph{}" "\emph{italic}", all
} // linenum if
local newline "`newline'`newword' "
mac shift
} // w / while
file write new `"`macval(newline)'"' _n
file read original line
}
file close original
file close new
} // foreach tab
________________________________________
From: Stephanie Vermeer [mailto:[email protected]]
Sent: Monday, December 06, 2010 7:20 PM
To: [email protected]
Subject: Stata
Dear Andreas,
Did you find already an solution to highlight the significant results in
bold, using stata and -esttab- or -estout-? I'm dealing with the same
question!
Thanks in advance,
Stephanie
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Andreas Peichl
Sent: Saturday, October 16, 2010 7:35 PM
To: [email protected]
Subject: st: Output regression table with significance at some level
indicate in bold font
Dear Statalisters,
I'm estimating regression models for 27 different countries and I'm using
-estout- and / or -eststo-, -esttab- to output the regression results to
LaTeX. The tables are getting rather big and I would like to highlight the
significant results in bold (ot italics) and surpress the standard errors /
t-stats as well as the "stars". Is it possible to do this with -estout- (I
couldn't find it in the help) or with any other program?
Any help is appreciated.
Cheers,
Andreas
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/