1

これはおそらく非常に簡単ですが、過去数時間オンラインでドキュメントと可能な例を調べた後、私はそれを理解できません.

DO ファイルによって大幅にクリーンアップされる大規模なデータセット (スプレッドシート) があります。DO ファイルでは、クリーニングされたデータの特定の変数を temp .csv として保存し、いくつかの Python スクリプトを実行して、新しい CSV を生成し、その出力をクリーニングされたデータに追加します。

それが不明な場合は、ここに例を示します。

After cleaning my data set (XYZ) goes from variables A to Z with 100 observations. I want to take variables A and D through F and save it as test.csv. I then want to run a python script that takes this data and creates new variables AA to GG. I want to then take that information and append it to the XYZ dataset (making the dataset now go from A to GG with 100 observations) and then be able to run a second part of my DO file for analysis.

私はこれを手動で行ってきましたが、問題はありませんが、ファイルはすぐに変更され始め、多くの時間を節約できます.

4

2 に答える 2

1

これは機能しますか(Pythonにアクセスできると仮定します

tempfile myfiletemp
save `myfiletemp'
outsheet myfile1.csv
shell python.exe myscript.py
insheet myfile2.csv, clear
append using `myfiletemp'
于 2012-10-22T17:40:30.883 に答える
0

Stata に「help shell」と入力します。あなたがしたいことは、Stata からシェルアウトし、Python を呼び出し、Python スクリプトが完了した後に、Stata がやりたいことを再開することです。

于 2012-10-22T17:38:16.047 に答える