自动化生成报告

发布于 2024-08-10 03:24:33 字数 160 浏览 7 评论 0原文

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

We are using Stata to combine and analyze data for all of our agencies in a district each month. I'd like to somehow create reports of the data analysis automatically for these monthly reports. The report includes a summary table of the reported indicators, a couple of graphics of the key indicators, and an analysis table showing statistically significant differences in the data groups. I'd like these to be in pdf and automatically emailed out to the agencies. Any ideas on software I can use to automate this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪痕残 2024-08-17 03:24:33

由于您使用 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,则可以使用 Terminal -convert- 实用程序或自动程序来执行此操作,或者这里有一些其他解决方案:http://codesnippets.joyent.com/posts/show/1601
我不使用 Windows,所以我不确定该操作系统的解决方案。祝你好运。

Since you're using Stata to do the analysis, you can let it do the heavy lifting of the report automation as well.

The trick is using a Stata package like -rtfutil- to export the tables and graphics you describe to a single document. At that point you'll need to convert that to pdf before emailing it.

Here some sample code for using -rtfutil- automate the creation of a document including a table and two graphics (plus some paragraphs of text) in a RTF document(using the system dataset "auto.dta" as an example):

    ******

    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'

    ******

This will put all the elements you asked about into a RTF document (be careful with any issues with wrapping of this code when copy/paste it from the webpage).
In your question, you also mentioned wanting to create a PDF during this process. Here you'll need to go to use some non-Stata solution. If you're using Mac OSX you can use the Terminal -convert- utility or automator to do this, or here are some other solutions: http://codesnippets.joyent.com/posts/show/1601
I don't use windows so I'm not sure about solutions with that OS. Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文