Stata

Notitle

Stata statistical software is a complete, integrated statistical software package that provides everything you need for data analysis, data management, and graphics.

The Stata/MP8 perpetual licence on Apocrita allows for up to 8 cores per process and 6 concurrent users.

Stata can be run on the command line and using a GUI. Both types of instance must be done via the cluster's queuing system.

Stata is available as a module on Apocrita.

Usage

To use Stata you must first load the module:

$ module load stata
$ stata -h
stata-mp:  usage:  stata-mp [-h -q -s -b] ["stata command"]
        where:
             -h      show this display
             -q      suppress logo, initialization messages
             -s      "batch" mode creating .smcl log
             -b      "batch" mode creating .log file

Example jobs

Interactive Stata

Interactive mode can be useful for diagnosing issues with your Stata code.

Text mode

Please use qlogin and execute:

module load stata
stata

GUI

Run qsh to get a session on a compute node and display an xterm window, then execute:

module load stata
xstata

X Forwarding Required

To do this you must have logged in to the cluster with [X-windows forwarding](logged into Apocrita](/intro/login#x-windows) enabled.

Additional memory and CPU requirements can be added to the qsh command in the same way as the qsub command, as per the section on submitting jobs

Use of the login nodes

Please ensure stata and xstata are run only via the scheduling system; running on the login nodes is against the Usage Policy.

Non-interactive Stata (batch mode)

Batch mode preferred

HPC clusters are designed to run queued jobs via the command line. Typically the graphical and interactive modes should only be used during debugging or early testing of your job, and the command line batch mode used to submit jobs to the scheduler queue to be run as soon as your job is ready to run correctly.

Running a job via the scheduler requires creation of a Stata code file e.g. my_code.do and a job submission script. For example, to request 4 cores and 8GB total RAM, create a job submission script called submit_stata.sh:

#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 4
#$ -l h_vmem=2G
#$ -l h_rt=4:0:0

module load stata

# Run the Stata code my_code.do
stata -b do my_code.do

Submit your job to the scheduler with the qsub command:

qsub submit_stata.sh

Custom Stata commands using "ado" files

Users can extend the Stata programming language by writing custom commands. These are saved as ado-files. Stata checks the ado-files when a non-system Stata command is executed.

Use the sysdir command to list where Stata searches for ado-files. On Apocrita, the PERSONAL directory is expected at ~/ado/personal/, which needs to exist. If the directory does not exist, execute:

mkdir -p ~/ado/personal

You can then save your "ado" files in that folder and Stata should be able to find them.

References