Using Stata on Code Ocean

Packages, image rendering, and command line execution.

Shahar Zaks avatar
Written by Shahar Zaks
Updated over a week ago

Can I render my results as PNG files?

Stata on Linux does not currently render PNGs. Attempting to do so yields the error:
translator Graph2png not found
Instead, render the results as PDF or EPS files. 

How do I execute Stata from the command line?  

For a hypothetical file main.do , execute stata do main
You can also execute individual commands, e.g. stata q 'insheet using ../data/my_data.csv, clear'
The command stata-mp  will launch a more powerful version of Stata.

Can I install specific versions of SSC packages?

Currently, the Boston College Statistical Software Components (SSC) archive does not support this.

Nick Cox writes on the Statalist forum;
"SSC works in the simplest possible way. If authors send new versions of existing files to Kit Baum, they just overwrite the previous versions. There is no archive of the archive so far as I know, and I've been sending stuff to it for a while."

This is why you see "N/A" in the version box of SSC packages, and also why that box is greyed out when you are specifying packages.

Can I use 'net' to install packages on Code Ocean?

Yes. The best way to do this is via the postInstall script. To install  weaver, use the following line:
stata -q 'net install weaver, replace from("https://raw.githubusercontent.com/haghish/weaver/master/")'

Where are my installed ado files stored?

/root/ado , organized by the first letter of the package, i.e.: /root/ado/m  or /root/ado/s.

What about packages that are not on SSC or GitHub?

If you find a URL with the relevant ado file, use the postInstall script to save the relevant file to the user-written ado files path. To install "meta," you could write:

#!/bin/bash
mkdir -p /root/ado/plus/m
curl -s http://fmwww.bc.edu/RePEc/bocode/m/meta.ado > /root/ado/plus/m/meta.ado

ado files are organized in folders by first letter.

Can I check out some published examples?

Certainly!

Did this answer your question?