自动化生成报告[关闭]
题
我们正在使用的Stata在一个地区每个月结合和分析所有的机构的数据。我想以某种方式对这些月度报告自动生成的数据分析报告。该报告包括的报告显示指标在数据统计组差异显著的汇总表,一对夫妇的关键指标图形和分析表。我想这是PDF和自动发送出去的机构。在软件的任何想法,我可以用它来自动完成这个?
解决方案
由于您使用的Stata做了分析,你可以让它做报告自动化的繁重以及。
诀窍是使用Stata的包等-rtfutil-导出你描述到单个文档中的表和图表。在这一点上,你需要将其转换成PDF格式发送电子邮件之前。
下面使用-rtfutil-自动化包括表格和两个图形(加上文本的一些段落)一个RTF文件中(使用系统数据集“auto.dta”作为示例)的文档的创建一些示例代码:
******
clear
//RTF UTILITY FOR INSERTING GRAPHICS & TABLES//
local sf "/users/ppri/desktop/"
//SETUP
sysuse auto, clear
twoway scatter mpg price, mlabel(make) || lfitci mpg price
graph export "`sf'myplot1.eps", replace
twoway scatter price mpg, mlabel(make) by(for)
graph export "`sf'myplot2.eps", replace
**
tempname handle1
//RTFUTIL
rtfopen `handle1' using "`sf'mydoc1.rtf", replace
file write `handle1' _n _tab "{\pard\b SAMPLE DOCUMENT \par}" _tab _n
file write `handle1' _n "{\line}"
// Figure1
file write `handle1' "{\pard\b FIGURE 1: Plot of Price\par}" _n
rtflink `handle1' using "`sf'myplot1.eps"
// Figure2
file write `handle1' _n "{\page}" _n /*
*/ "{\pard Here is the plot and a paragraph about it. Here is the plot and a paragraph about it. Here is the plot and a paragraph about it. Here is the plot and a paragraph about it.....blah blah blah blah blah \line}" _n
file write `handle1' _n "{\line}"
file write `handle1' "{\pard\b FIGURE2: Plots of Price vs. MPG\par}" _n
rtflink `handle1' using "`sf'myplot2.eps"
// Table Title
file write `handle1' _n "{\page}" _n
file write `handle1' _n "{\par\pard}" _n /*
*/ "{\par\pard HERE IS A TABLE WITH THE CARS: \par\pard}" _n
file write `handle1' _n "{\par\pard}" _n
// Summary Table
rtfrstyle make mpg weight, cwidths(2000 1440 1440) local(b d e)
listtex make foreign mpg if mpg<15, /*
*/ handle(`handle1') begin("`b'") delim("`d'") end("`e'") /*
*/ head("`b'\ql{\i Make}`d'\qr{\i Foreign}`d'\qr{\i MPG }`e'")
file write `handle1' _n "{\line}"
file write `handle1' _n _tab(2) /*
*/ "{\pard\b Sources: Census Data, etc... \par}" _n _n
**
rtfclose `handle1'
******
这将会把所有你问到一个RTF文档中的元素(注意与此代码的网页时复制/粘贴的包装的任何问题)。结果 在你的问题,你也提到希望在此过程中创建PDF文件。在这里,您将需要去使用一些非Stata的解决方案。如果您使用的是Mac OSX,你可以使用终端-convert-实用程序或自动机来做到这一点,还是这里有一些其他的解决方案:的 http://codesnippets.joyent.com/posts/show/1601 结果 我不使用Windows,所以我不知道与该操作系统的解决方案。好运。
不隶属于 StackOverflow