0
votes

for simplification, let's assume following script to create a simple regression table:

sysuse auto
eststo clear
qui regress price weight mpg

esttab using "table.rtf", cells(t) mtitles onecell nogap ///
stats(N, labels("Observations")) label ///
compress replace
eststo clear

Output:

(1)
.
t
Weight (lbs.)   2.723238
Mileage (mpg)   -.5746808
Constant    .541018
Observations    74

Question:

Would it be possible to mark every t-value above 0.5 or below 0.5 with an asterisk? (= greater than absolute value 0.5) Please note: In the specific application case, I can't work with given p-values, and need a custom solution that works with thresholds of t.

Desired outcome:

(1)
.
t
Weight (lbs.)   2.723238*
Mileage (mpg)   -.5746808*
Constant    .541018*
Observations    74

Crossposting can be found here:

Thank you for your help!

1

1 Answers

1
votes

You cannot do this directly with estout but the following works all the same:

sysuse auto, clear
regress price weight mpg

quietly esttab,  mtitles onecell nogap stats(N, labels("Observations")) label ///
compress replace star staraux

matrix A = r(coefs)
matrix A = A[1...,2]
svmat A

generate A2 = "*" if abs(A1) >= 0.5
generate A4 = string(A1) + A2

local names : rownames A
generate A3 = ""
forvalues i = 1 / `: word count `names'' {
  replace A3 = `"`: word `i' of `names''"' in `i'
}

list A3 A4 if !missing(A3)

     +---------------------+
     |     A3           A4 |
     |---------------------|
  1. | weight    2.723238* |
  2. |    mpg   -.5746808* |
  3. |  _cons     .541018* |
     +---------------------+

preserve
keep if !missing(A3)
export delimited A3 A4 using table.txt, delimiter(" ") novarnames 
restore

You will have to do some more gymnastics to get the variable labels etc.