Stata

From FarmShare

(Difference between revisions)
Jump to: navigation, search
m (Desktop Mode)
 
(17 intermediate revisions not shown)
Line 1: Line 1:
-
Running stata in batch mode on the barleys:
+
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>
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
$ module spider stata  
-
$ cat test.do
+
-
clear
+
-
sysuse auto
+
-
describe
+
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
-
$ echo "/usr/sweet/bin/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.
+
----------------------------------------------------------------------------
 +
  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.
-
==using module==
+
    Versions:
-
We're trying to move away from /usr/sweet/bin, using [[FarmShare software | modules]] instead.  So your stata session looks more like:
+
        stata-se/14.2
-
 
+
        stata-se/15
-
<pre>
+
        stata-se/16
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [130]
+
-
$ source /mnt/glusterfs/software/free/modules/tcl/init/bash
+
-
+(0):WARN:0: Directory '/afs/ir/users/c/h/chekh/.modules' not found
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
-
$ module avail
+
-
--------------------- /mnt/glusterfs/software/free/modules/tcl/modulefiles ---------------------
+
-
MATLAB-R2009b    MATLAB-R2011b    R-2.15.0          StatTransfer-11.2 StataSE-12.1     
+
-
MATLAB-R2010b    MATLAB-R2012a    StatTransfer-10.1 StataMP-12.1     
+
-
------------------------------------------- Aliases --------------------------------------------
+
-
------------------------------------------- Versions -------------------------------------------
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
-
$ module load StataSE-12.1
+
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
-
$ stata
+
...
...
</pre>
</pre>
-
But that also means you need to modify your job script to point to the right MATLAB.  So you'll want to add that "module load" command to that job script.
+
==Interactive Sessions==
 +
===Terminal Mode===
 +
To start an interactive session, load one of the modules and run <code>stata-se</code> (or <code>stata-mp</code>):
-
 
-
Job script:
 
<pre>
<pre>
-
#!/bin/bash
+
$ module load stata-se
-
source /mnt/glusterfs/software/free/modules/tcl/init/bash
+
$ which stata-se
-
module load StataSE-12.1
+
/farmshare/software/non-free/stata-se/16/stata-se
-
stata -b do test
+
$ stata-se
-
</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 &
 +
</pre>
-
Note:  Your site can add messages to the introduction by editing the file
+
==Non-interactive jobs==
-
      stata.msg in the directory where Stata is installed.
+
You can also run Stata non-interactively using the <code>do</code> command, producing a <code>.log</code> file containing results:
-
. do test  
+
<pre>
 +
$ 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
 +
...
 +
</pre>
-
. clear
+
===Batch jobs===
 +
Or, submit a batch job to run on one of the compute nodes:
-
. sysuse auto
+
<pre>
-
(1978 Automobile Data)
+
$ module load stata-se
-
 
+
$ sbatch --wrap='stata -b do test.do'
-
. 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==
+
You can also write and submit a traditional Slurm job script:
-
  cd /mnt/glusterfs/chekh/stata-mp-test
+
-
My test.do :
 
<pre>
<pre>
-
clear
+
$ cat test.sh
-
sysuse auto
+
#!/bin/bash
-
describe
+
module load stata-se
 +
stata-se -b do test.do
 +
$ sbatch test.sh
 +
$ ls test.log
 +
test.log
</pre>
</pre>

Latest revision as of 15: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