Search code examples
stataslurm

Slurm job arrays with Stata


I want to run some Stata code in parallel using slurm job arrays.

I know that I can run 100 jobs doing:

#!/bin/bash
#SBATCH --array=1-100

module load stata
stata my_code.do $SLURM_ARRAY_TASK_ID

Now each code will have to read a file that takes the slurm_array_task_id.

I.e. inside the my_code.do there is an instruction that makes:

use "my_data.dta" in `j', clear

where `j' is the slurm array task id. How can I do this?


Solution

  • You can access the first argument passed to your do-file with `1'. So I think in your code example you could just put:

    use "my_data.dta" in `1', clear
    

    More info here.