Stata

From FarmShare

(Difference between revisions)
Jump to: navigation, search
m (Desktop Mode)
 
(11 intermediate revisions not shown)
Line 1: Line 1:
-
We now have Stata version 13 installed. Try the commands 'module avail', 'module load statase':
+
Stata is an integrated statistical software package for data analysis, data management, and graphics.
 +
 
 +
==Installed Versions==
 +
Stata/SE and Stata/MP versions 14, 15, and 16 are available on FarmShare:
<pre>
<pre>
-
$ module help statase
+
$ module spider stata
 +
----------------------------------------------------------------------------
 +
  stata-mp:
 +
----------------------------------------------------------------------------
 +
    Description:
 +
      Integrated statistical software package for data analysis, data
 +
      management, and graphics.
-
-------------------- Module Specific Help for "statase/13" ---------------------
+
    Versions:
-
This is Stata/SE version 13
+
        stata-mp/14.2
-
 
+
        stata-mp/15
-
        xstata-se          (Run windowed version of Stata/SE)
+
        stata-mp/16
-
        stata-se           (Run console  version of Stata/SE)
+
...
 +
----------------------------------------------------------------------------
 +
  stata-se:
 +
----------------------------------------------------------------------------
 +
    Description:
 +
      Integrated statistical software package for data analysis, data
 +
      management, and graphics.
 +
    Versions:
 +
        stata-se/14.2
 +
        stata-se/15
 +
        stata-se/16
 +
...
</pre>
</pre>
-
We actually have three versions installed.  If you run 'stata', you get Stata/IC, if you run 'stata-se', you get 'Stata/SE', if you 'module load statamp && stata-mp', you get Stata/MP.
+
==Interactive Sessions==
-
 
+
===Terminal Mode===
-
==batch mode==
+
To start an interactive session, load one of the modules and run <code>stata-se</code> (or <code>stata-mp</code>):
-
 
+
-
Running stata in batch mode in general, use the '-b do' parameter.
+
-
 
+
-
Running stata in batch mode on the barley via qsub.
+
<pre>
<pre>
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
$ module load stata-se
-
$ cat test.do
+
$ which stata-se
-
clear
+
/farmshare/software/non-free/stata-se/16/stata-se
-
sysuse auto
+
$ stata-se
-
describe
+
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ echo "stata -b do test2.do" | qsub -cwd -l hostname=barley05
+
-
Your job 5725 ("STDIN") has been submitted
+
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ ls -ltr |tail -n 4
+
-
-rw-r--r-- 1 chekh root      27 Nov  7 17:27 test2.do
+
-
-rw-r--r-- 1 chekh root      0 Nov  7 17:28 STDIN.o5725
+
-
-rw-r--r-- 1 chekh root      0 Nov  7 17:28 STDIN.e5725
+
-
-rw-r--r-- 1 chekh root    2400 Nov  7 17:28 test2.log
+
-
</pre>
+
-
 
+
-
Looks like stata doesn't print anything to stdin or stderr, but does create a .log file with the same name as your .do file.
+
-
 
+
-
 
+
-
 
+
-
Job script:
+
-
<pre>
+
-
#!/bin/bash
+
-
source /mnt/glusterfs/software/free/modules/tcl/init/bash
+
-
module load StataSE-12.1
+
-
stata -b do test
+
-
</pre>
+
-
 
+
-
Full session:
+
-
<pre>
+
-
 
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ qsub -cwd -l mem_free=10M script2.submit
+
-
Your job 167221 ("script2.submit") has been submitted
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ qstat
+
-
job-ID  prior  name      user        state submit/start at    queue                          slots ja-task-ID
+
-
-----------------------------------------------------------------------------------------------------------------
+
-
167221 0.00000 script2.su chekh        qw    04/27/2012 15:21:30                                    1       
+
-
...
+
-
...
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ cat test.log
+
   ___  ____  ____  ____  ____ (R)
   ___  ____  ____  ____  ____ (R)
  /__    /  ____/  /  ____/
  /__    /  ____/  /  ____/
-
___/  /  /___/  /  /___/  12.1  Copyright 1985-2011 StataCorp LP
+
___/  /  /___/  /  /___/  16.1  Copyright 1985-2019 StataCorp LLC
   Statistics/Data Analysis            StataCorp
   Statistics/Data Analysis            StataCorp
                                       4905 Lakeway Drive
                                       4905 Lakeway Drive
-
                                      College Station, Texas 77845 USA
+
    Special Edition                  College Station, Texas 77845 USA
                                       800-STATA-PC        http://www.stata.com
                                       800-STATA-PC        http://www.stata.com
                                       979-696-4600        stata@stata.com
                                       979-696-4600        stata@stata.com
                                       979-696-4601 (fax)
                                       979-696-4601 (fax)
 +
...
 +
</pre>
-
23-user Stata network perpetual license:
+
===Desktop Mode===
-
      Serial number: 40120564988
+
If you [https://srcc.stanford.edu/farmshare2/connecting connect] using X11 for remote display, you can run <code>xstata-se</code> (or <code>xstata-mp</code>) to start the desktop (graphical) version of the application:
-
        Licensed to: Jane Tansuwan
+
-
                      Stanford University
+
-
Notes:
+
<pre>
-
      1. Command line editing disabled
+
$ ssh -Y sunetid@rice.stanford.edu
-
      2. Stata running in batch mode
+
rice $ module load stata-se
-
 
+
rice $ xstata-se &
-
Note:  Your site can add messages to the introduction by editing the file
+
-
      stata.msg in the directory where Stata is installed.
+
-
 
+
-
. do test
+
-
 
+
-
. clear
+
-
 
+
-
. sysuse auto
+
-
(1978 Automobile Data)
+
-
 
+
-
. describe
+
-
 
+
-
Contains data from /mnt/glusterfs/software/non-free/stata-se-12/ado/base/a/auto
+
-
> .dta
+
-
  obs:            74                          1978 Automobile Data
+
-
vars:            12                          13 Apr 2011 17:45
+
-
size:        3,182                          (_dta has notes)
+
-
-------------------------------------------------------------------------------
+
-
              storage  display    value
+
-
variable name  type  format      label      variable label
+
-
-------------------------------------------------------------------------------
+
-
make            str18  %-18s                  Make and Model
+
-
price          int    %8.0gc                Price
+
-
mpg            int    %8.0g                  Mileage (mpg)
+
-
rep78          int    %8.0g                  Repair Record 1978
+
-
headroom        float  %6.1f                  Headroom (in.)
+
-
trunk          int    %8.0g                  Trunk space (cu. ft.)
+
-
weight          int    %8.0gc                Weight (lbs.)
+
-
length          int    %8.0g                  Length (in.)
+
-
turn            int    %8.0g                  Turn Circle (ft.)
+
-
displacement    int    %8.0g                  Displacement (cu. in.)
+
-
gear_ratio      float  %6.2f                  Gear Ratio
+
-
foreign        byte  %8.0g      origin    Car type
+
-
-------------------------------------------------------------------------------
+
-
Sorted by:  foreign
+
-
 
+
-
.
+
-
end of do-file
+
</pre>
</pre>
-
==stata-mp test==
+
==Non-interactive jobs==
-
  cd /mnt/glusterfs/chekh/stata-mp-test
+
You can also run Stata non-interactively using the <code>do</code> command, producing a <code>.log</code> file containing results:
-
My test.do :
 
<pre>
<pre>
-
clear
+
$ module load stata-se
 +
$ cat test.do
sysuse auto
sysuse auto
describe
describe
 +
$ stata -b do test.do
 +
$ cat test.log
 +
Contains data from /farmshare/software-prod/non-free/stata-se/16/ado/base/a/aut
 +
> o.dta
 +
  obs:            74                          1978 Automobile Data
 +
vars:            12                          13 Apr 2018 17:45
 +
...
</pre>
</pre>
-
My job.script:
+
===Batch jobs===
-
<pre>
+
Or, submit a batch job to run on one of the compute nodes:
-
#!/bin/bash
+
-
# use the current directory
+
-
#$ -cwd
+
-
# mail this address
+
-
#$ -M chekh@stanford.edu
+
-
# send mail on begin, end, suspend
+
-
#$ -m bes
+
-
# copy current env vars to job
+
-
#$ -V
+
-
stata-mp -b do test.do
+
-
</pre>
+
-
The job script uses '-V' to copy the env vars from your current session, so need to load the right module first:
 
<pre>
<pre>
-
[chekh@corn13.stanford.edu] /mnt/glusterfs/chekh/stata-mp-test [0]
+
$ module load stata-se
-
$ module load StataMP-12.1
+
$ sbatch --wrap='stata -b do test.do'
-
[chekh@corn13.stanford.edu] /mnt/glusterfs/chekh/stata-mp-test [0]
+
-
$ which stata-mp
+
-
/mnt/glusterfs/software/non-free/stata-mp-12/stata-mp
+
</pre>
</pre>
-
Test that the command works outside of grid engine:
+
You can also write and submit a traditional Slurm job script:
-
  stata-mp -b do test.do
+
-
It produces a test.log as expected.
 
-
 
-
Submit the job:
 
<pre>
<pre>
-
[chekh@corn13.stanford.edu] /mnt/glusterfs/chekh/stata-mp-test [0]
+
$ cat test.sh
-
$ qsub job.script
+
#!/bin/bash
-
Your job 416828 ("job.script") has been submitted
+
module load stata-se
-
</pre>
+
stata-se -b do test.do
-
 
+
$ sbatch test.sh
-
The job is sitting there a long time because the cluster is busy and there are no immediately open slots:
+
$ ls test.log
-
<pre>
+
test.log
-
$ qstat
+
-
job-ID  prior  name      user        state submit/start at    queue                          slots ja-task-ID
+
-
-----------------------------------------------------------------------------------------------------------------
+
-
416828 0.37250 job.script chekh        qw    09/04/2012 17:04:24             
+
-
</pre>
+
-
 
+
-
Submit to the test queue instead:
+
-
  qsub -l testq=1 job.script
+
-
 
+
-
It runs immediately and produces the expected test.log file.
+
-
<pre>
+
-
[chekh@corn13.stanford.edu] /mnt/glusterfs/chekh/stata-mp-test [0]
+
-
$ ls -ltr
+
-
total 16
+
-
-rw-r--r-- 1 chekh root  27 Sep  4 16:59 test.do
+
-
-rw-r--r-- 1 chekh root  199 Sep  4 17:00 job.script
+
-
-rw-r--r-- 1 chekh root 2434 Sep  4 17:02 test.log.orig
+
-
-rw-r--r-- 1 chekh root    0 Sep  4 17:06 job.script.o416829
+
-
-rw-r--r-- 1 chekh root    0 Sep  4 17:06 job.script.e416829
+
-
-rw-r--r-- 1 chekh root 2434 Sep  4 17:06 test.log
+
</pre>
</pre>

Latest revision as of 14:46, 3 March 2020

Stata is an integrated statistical software package for data analysis, data management, and graphics.

Contents

Installed Versions

Stata/SE and Stata/MP versions 14, 15, and 16 are available on FarmShare:

$ module spider stata 

----------------------------------------------------------------------------
  stata-mp:
----------------------------------------------------------------------------
    Description:
      Integrated statistical software package for data analysis, data
      management, and graphics.

     Versions:
        stata-mp/14.2
        stata-mp/15
        stata-mp/16
...
----------------------------------------------------------------------------
  stata-se:
----------------------------------------------------------------------------
    Description:
      Integrated statistical software package for data analysis, data
      management, and graphics.

     Versions:
        stata-se/14.2
        stata-se/15
        stata-se/16
...

Interactive Sessions

Terminal Mode

To start an interactive session, load one of the modules and run stata-se (or stata-mp):

$ module load stata-se
$ which stata-se
/farmshare/software/non-free/stata-se/16/stata-se
$ stata-se

  ___  ____  ____  ____  ____ (R)
 /__    /   ____/   /   ____/
___/   /   /___/   /   /___/   16.1   Copyright 1985-2019 StataCorp LLC
  Statistics/Data Analysis            StataCorp
                                      4905 Lakeway Drive
     Special Edition                  College Station, Texas 77845 USA
                                      800-STATA-PC        http://www.stata.com
                                      979-696-4600        stata@stata.com
                                      979-696-4601 (fax)
...

Desktop Mode

If you connect using X11 for remote display, you can run xstata-se (or xstata-mp) to start the desktop (graphical) version of the application:

$ ssh -Y sunetid@rice.stanford.edu
rice $ module load stata-se
rice $ xstata-se &

Non-interactive jobs

You can also run Stata non-interactively using the do command, producing a .log file containing results:

$ module load stata-se
$ cat test.do
sysuse auto
describe
$ stata -b do test.do
$ cat test.log
Contains data from /farmshare/software-prod/non-free/stata-se/16/ado/base/a/aut
> o.dta
  obs:            74                          1978 Automobile Data
 vars:            12                          13 Apr 2018 17:45
...

Batch jobs

Or, submit a batch job to run on one of the compute nodes:

$ module load stata-se
$ sbatch --wrap='stata -b do test.do'

You can also write and submit a traditional Slurm job script:

$ cat test.sh
#!/bin/bash
module load stata-se
stata-se -b do test.do
$ sbatch test.sh
$ ls test.log
test.log
Personal tools
Toolbox
LANGUAGES