Skip to main content

Fun with Stata: Running Stata from your iPhone

There are literally tens of people out there in the world that have at some point or another thought "I really wish I could run something in Stata right now on my iPhone." Well, I recently killed some time making that a possibility.

In order to get results from Stata on your iPhone anywhere/anytime, this process requires 5 components:
(1) Stata (10 or later) installed on a Mac OSX (10.5 or later) that is always connected to the internet
(2) A Dropbox account linked to your Mac that has Stata installed
(3) iStata.scpt Applescript file to manage files put in Dropbox
(4) iStata.ado to run the file, log the output, and put it back in Dropbox
(5) the free application Plaintext for iPhone (or some equivalent) to write and view .do files written and run from your iPhone

You'll need to save the iStata.scpt and files into the folders referenced in these scripts in your Dropbox folders on your Mac OSX. Really, you can place these files/folders anywhere in your Dropbox that you'd like, but you need to change the paths in these scripts to point to the proper location.

The basic idea of the workflow is illustrated below. Basically, the process is to create the file "torun.txt" on your iPhone in the app Plaintext and then save it.  The scripts do all the work and send back a new file called "Results.txt" with the logfile of what you ran in Stata.

Here's a detailed look at how the programs and scripts work together to run the code you put in "torun.txt" on your iPhone:

(1) you create text file (called "torun.txt") of Stata commands in on your iPhone which is linked to your Dropbox account
(2) Once this text file ("torun.txt") is saved in your Dropbox account, your Mac OSX runs iPhone.scpt which converts the file to a .do file ("") and runs iStata.ado.
(3) iStata.ado creates a logfile, runs the "" commands, logging the output, and saves the results as "Results.txt" the "Results" subfolder in Dropbox
(4) "" replaces "torun.txt" in your iPhone Dropbox/Plaintext folder so that you can see what you ran (that is, the "torun.txt"/"" file is erased and replaced by "" in your Dropbox and the results are placed in the "Results" subfolder on Dropbox and the file is named "Results.txt").
(5) Each time you create and save "torun.txt", "" and "Results.txt" are created and "torun.txt" is erased.

See my software page for more on these scripts & other software for Stata & Mac OSX.


Post a Comment