-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvariables_and_coeffs.ado
executable file
·61 lines (49 loc) · 1.36 KB
/
variables_and_coeffs.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
program define variables_and_coeffs
// syntax , Filename(string) [Round(real 1)]
syntax using, [Round(real 1) Omitstandarderrors]
version 9.1
local N = e(N)
if ("`round'" == "") {
local r2 = e(r2)
}
else {
local r2 = round(e(r2),`round')
}
local r2 = e(r2)
local N = e(N)
tempname fh
file open `fh' `using', w replace all
local varnames1 : coln e(b)
local equation ""
foreach varn of local varnames1 {
cap local varlabel : variable label `varn'
if (_coef[`varn'] ~= 0) {
if ("`round'" == "") {
local coef = round(_coef[`varn'])
local se = round(_se[`varn'])
local t = round(_coef[`varn']/_se[`varn'])
}
else {
local coef = round(_coef[`varn'],`round')
local se = round(_se[`varn'],`round')
local t = round(_coef[`varn']/_se[`varn'],`round')
}
if ("`varn'" != "_cons") {
file write `fh' `""`varn'","`varlabel'","`coef'","`t'""' _n
if (`"`omitstandarderrors'"' == `""') {
file write `fh' `""","","(`se')""' _n
}
}
else {
file write `fh' `""Constant","Constant","`coef'","`t'""' _n
if (`"`omitstandarderrors'"' == `""') {
file write `fh' `""","","(`se')""' _n
}
}
}
}
// Lets put the number of observations and the R2 at the bottom
file write `fh' `""Number of obs","","`N'""' _n
file write `fh' `""R-squared","" ,"`r2'""' _n
file close `fh'
end