• Home
  • Get Started
  • About
  • Services
    • Research Software
    • Research Datasets
    • Compute
    • Storage
  • Knowledge Base
  • FAQ
  • Resources
  • Contact Us
  • Home
  • Get Started
  • About
  • Services
    • Research Software
    • Research Datasets
    • Compute
    • Storage
  • Knowledge Base
  • FAQ
  • Resources
  • Contact Us
home/Knowledge Base/Slurm Batch Jobs/Stata/Stata Tutorial

Stata Tutorial

In this tutorial, we will run a Stata program.

Stata Script

/* newVar.do */

/* Input data from fixed field file */
quietly infile using testData
list

/* create new variable */
generate v4=v3-v1
list

/* clear or save data environment */
clear
/* save newVar.out */

This code reads data from a file, creates a new variable (v4) by subtracting v1 from v3, and then clears the data environment or saves it to a file named newVar.out.

SLURM Script

#!/bin/bash
#
# [ newVar.sbatch ]
#
# This script runs an example  Stata  program and writes the screen
# output into the  newVar.log  file.
# -----------------------------------------------------------------
#
#
# Use environment modules to specify software and version.  Run the
#     "module avail" command to get list of installed software versions,
#     then replace the <X.Y.Z> with actual software version as shown below.
#
#     module purge
#     module load stata/<X.Y.Z>
#
#     For example:
#
#     rnd> module avail stata
#     ---------------------- /gridapps/modules -----------------------
#     stata-mp/15.1  stata-se/12.1  stata-se/15.1
#
#     rnd>
#     rnd> module  purge
#     rnd> module  load   stata-se/15.1
#     rnd>
# -----------------------------------------------------------------
#

  module  purge
  module  load   stata-se/17.0

  stata -b do newVar.do > newVar.log

You can run it by executing the following script:

sbatch newVar.sbatch

Related Articles
  • Creating a Python Virtual Environment
  • R Monte Carlo Simulation Tutorial
  • R Fitspline Tutorial
  • Common SLURM commands
  • MATLAB GPU Tutorial
  • SAS Tutorial

  R Monte Carlo Simulation Tutorial

Creating a Python Virtual Environment  

  • Home
  • Get Started
  • About
  • Services
  • Knowledge Base
  • FAQ
  • Resources
  • Contact Us
  • Copyright © 2023 Stern Center for Research Computing