-
Notifications
You must be signed in to change notification settings - Fork 17
/
edaladder.ado
executable file
·94 lines (70 loc) · 3.41 KB
/
edaladder.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
********************************************************************************
* Description of the Program - *
* EDA subroutine used to create ladders of powers graphs *
* *
* Program Output - *
* Creates series of ladder of powers graph GPHs and PDFs as well as *
* entries in the LaTeX document *
* *
* Lines - *
* 93 *
* *
********************************************************************************
*! edaladder
*! v 0.0.1
*! 17jul2018
// Drop program from memory if already loaded
cap prog drop edaladder
// Define program
prog def edaladder
// Version used to interpret code
version 14
// Syntax structure for edabar subroutine
syntax varlist(min=1) [if] [in], root(string asis) ///
[HISTOGRamopts(string asis) ///
scheme(passthru) ///
keepgph ]
// Mark only the observations to use
marksample touse, strok novarlist
// Add subheading to the LaTeX file
file write doc "\subsubsection{Ladder of Powers Transformation Graphs} \newpage\clearpage" _n
// Loop over continuous variables
foreach v of var `varlist' {
// Create the gladder graph
gladder `v' if `touse', `scheme' `histogramopts' ///
ti("Ladder of Powers Histograms for " `: char `v'[title]')
// Export to pdf
qui: gr export `"`root'/graphs/gladder`v'.pdf"', as(pdf) replace
// Create the qladder graph
qladder `v' if `touse', `scheme' `histogramopts' ///
ti("Ladder of Powers Quantile Normal Plots for " `:char `v'[title]')
// Export to pdf
qui: gr export `"`root'/graphs/qladder`v'.pdf"', as(pdf) replace
// Get LaTeX formatted variable name
texclean "`v'", r
// Store the variable name in the local macro vref
loc vref `r(clntex)'
// Get a LaTeX cleaned title string
texclean `"`: var l `v''"'
// Store the string in the local macro vlab
loc vlab `r(clntex)'
// Remove unneeded quotation marks from the label string
loc vlab : subinstr loc vlab `"""' "", all
// Add the graph to the LaTeX file
file write doc "\begin{figure}[h!]" _n
file write doc `"\caption{`vlab' Ladder of Powers Histograms \label{fig:gladder`vref'}}"' _n
file write doc `"\includegraphics[width=\textwidth]{gladder`v'.pdf}"' _n
file write doc "\end{figure} \newpage\clearpage" _n
file write doc "\begin{figure}[h!]" _n
file write doc `"\caption{`vlab' Ladder of Powers Quantile Normal Plots \label{fig:qladder`vref'}}"' _n
file write doc `"\includegraphics[width=\textwidth]{qladder`v'.pdf}"' _n
file write doc "\end{figure} \newpage\clearpage" _n
// Check if user wants to keep the GPH files
if "`keepgph'" != "" {
// Erase the GPH Files
qui: gr save `"`root'/graphs/gladder`v'.gph"', replace
qui: gr save `"`root'/graphs/qladder`v'.gph"', replace
} // End of Keep Stata graph files option
} // End Loop over continuous variables
// End program definition
end