首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于生成报告的自动化

用于生成报告的自动化
EN

Stack Overflow用户
提问于 2009-11-02 07:59:43
回答 1查看 944关注 0票数 4

我们每个月都使用Stata来合并和分析我们在一个地区的所有机构的数据。我想以某种方式为这些月度报告自动创建数据分析报告。该报告包括所报告指标的汇总表、几个关键指标的图表,以及显示数据组中统计上显著差异的分析表。我希望这些是pdf格式,并自动通过电子邮件发送给机构。对于我可以使用的自动化软件,有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-02 08:33:34

既然您使用Stata进行分析,那么您也可以让它来完成报告自动化的繁重工作。

诀窍是使用像rtfutil这样的Stata包将所描述的表格和图形导出到单个文档中。在这一点上,你需要在通过电子邮件发送之前将其转换为pdf。

下面是一些使用-rtfutil- automate创建文档的示例代码,该文档在RTF文档中包含一个表和两个图形(以及一些文本段落)(以系统数据集"auto.dta“为例):

代码语言:javascript
复制
    ******

    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,你可以使用终端转换工具或自动化来做这件事,或者这里有一些其他的解决方案:http://codesnippets.joyent.com/posts/show/1601

我不使用windows,所以我不确定使用该操作系统的解决方案。祝好运。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1658843

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档