Techniques for Automating Excel & Stata Interaction

August 26th, 2008 § 0 comments

The trick is to write do file and use command line.

  • Use VBA to write STATA do file. Example:
        fnum = FreeFile()
        Open "PathtoDofile.do" For Output As fnum
        Print #fnum, "reg income educ"
        Close #fnum
        
  • Use VBA to run do file. Actually it’s VBA asking command line to ask STATA to do the do file.
        Shell("Pathtowsestata.exe do PathtoDofile.do")
        

Category Brain

Tagged ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>