I have a Python script, which calls several Stata do
files:
from subprocess import call
Stata_exec = "D:/Stata 12 MP2/StataMP-64.exe"
dofile = "D:/Test.do"
call( "\"{0}\" do /e \"{1}\"".format(Stata_exec, dofile), shell=True)
Here is a test do
file:
/*
Merge some big files
*/
clear *
// Create Dataset A (8000 variables, 300 observations)
set obs 300
gen ID = _n
forval i = 1/8000 {
gen variableA`i' = runiform()
}
tempfile dataA
save "`dataA'"
// Dataset B (5000 variables, 300 observations)
clear
set obs 300
gen ID = _n
forval i = 1/5000 {
gen variableB`i' = runiform()
}
sort ID
// Attempt merge
merge 1:1 ID using `dataA'
exit, clear
I would like to have the progress of the do
file piped to the console in real time, so it will be integrated with the other Python output.
Is this possible?
from Stata batch called from Python: Pipe Stata console output to command line
No comments:
Post a Comment