1 Star 0 Fork 3

善衡/eda

forked from 连享会/eda 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
edapie.ado 3.18 KB
一键复制 编辑 原始数据 按行查看 历史
********************************************************************************
* Description of the Program - *
* EDA subroutine used to create pie charts *
* *
* Program Output - *
* Creates pie chart GPH and PDF as well as entries in the LaTeX document *
* *
* Lines - *
* 98 *
* *
********************************************************************************
*! edapie
*! v 0.0.1
*! 17jul2018
// Drop program from memory if already loaded
cap prog drop edapie
// Define program
prog def edapie
// Version used to interpret code
version 14
// Syntax structure for edabar subroutine
syntax varlist(min=1) [if] [in], root(string asis) ///
[PIECHartopts(string asis) ///
scheme(passthru) ///
keepgph MISSing byvars(varlist) byseq ]
// Mark only the observations to use
marksample touse, strok novarlist
// No byvars argument
if `"`byvars'"' == "" {
// Add subheading to the LaTeX file
file write doc "\subsubsection{Pie Charts}" _n
// Create bar graphs for the categorical variables
foreach v of var `varlist' {
// Get number of rows for the legend for this variable
loc leg legend(rows(`:char `v'[lrows]') symy(1.85) symx(1.85))
// Create pie chart
gr pie if `touse', over(`v') `piechartopts' ti(`:char `v'[title]') ///
note("Created on: `c(current_date)' at: `c(current_time)'") ///
`missing' `scheme'
// Export to .pdf file
qui: gr export `"`root'/graphs/pie`v'.pdf"', as(pdf) replace
// Check if user wants to keep the GPH files
if "`keepgph'" != "" {
// Define local macro with syntax to remove file
qui: gr save `"`root'/graphs/pie`v'.gph"', replace
} // End IF Block to remove .gph files
// Get LaTeX formatted variable name
texclean `"`v'"', r
// Store the variable name in vref
loc vref `r(clntex)'
// Get LaTeX formatted variable label
texclean `"`: var l `v''"'
// Store the variable label in vlab
loc vlab `r(clntex)'
// Add the graph to the LaTeX file
file write doc "\begin{figure}[h!]" _n
file write doc `"\caption{Pie Chart of `vlab' \label{fig:pie`vref'}}"' _n
file write doc `"\includegraphics[width=\textwidth]{pie`v'.pdf}"' _n
file write doc "\end{figure} \newpage\clearpage" _n
} // End loop over categorical variables
} // End IF Block for no byvars argument
// sequential by graphs
else if `"`byvars'"' != "" & "`byseq'" != "" {
} // End ELSEIF Block for sequential by graphs
// Lattice graphs
else if `"`byvars'"' != "" & "`byseq'" == "" {
} // End ELSE IF Block for Lattice style graphs
// End of subroutine definition
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jerryyang66/eda.git
git@gitee.com:jerryyang66/eda.git
jerryyang66
eda
eda
master

搜索帮助