4

私たちは Stata を使用して、毎月、地区内のすべての機関のデータを組み合わせて分析しています。これらの月報をどうにかしてデータ分析のレポートを自動で作成したいです。レポートには、報告された指標の要約表、主要な指標のいくつかの図、およびデータ グループの統計的に有意な差を示す分析表が含まれます。これらを PDF にして、代理店に自動的に電子メールで送信することを希望します。これを自動化するために使用できるソフトウェアに関するアイデアはありますか?

4

1 に答える 1

3

分析を行うためにStataを使用しているので、レポートの自動化の面倒な作業も行うことができます。

秘訣は、-rtfutil-のようなStataパッケージを使用して、記述したテーブルとグラフィックを1つのドキュメントにエクスポートすることです。その時点で、メールで送信する前にPDFに変換する必要があります。

ここでは、-rtfutil-を使用するためのサンプルコードを使用して、RTFドキュメントにテーブルと2つのグラフィック(およびテキストの段落)を含むドキュメントの作成を自動化します(例としてシステムデータセット「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ドキュメントに配置されます(Webページからコピー/貼り付けするときにこのコードをラップする際の問題に注意してください)。
あなたの質問では、このプロセス中にPDFを作成したいとも述べました。ここでは、Stata以外のソリューションを使用する必要があります。Mac OSXを使用している場合は、Terminal -convert-ユーティリティまたはautomatorを使用してこれを行うことができます。または、他の解決策もあります。http: //codesnippets.joyent.com/posts/show/1601Windows
を使用していませんそのため、そのOSのソリューションについてはよくわかりません。幸運を。

于 2009-11-02T00:33:34.373 に答える