Stata

From FarmShare

(Difference between revisions)
Jump to: navigation, search
m (Desktop Mode)
 
(20 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
+
  stata-mp:
-
describe
+
----------------------------------------------------------------------------
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
    Description:
-
$ echo "/usr/sweet/bin/stata -b do test2.do" | qsub -cwd -l hostname=barley05
+
      Integrated statistical software package for data analysis, data
-
Your job 5725 ("STDIN") has been submitted
+
      management, and graphics.
-
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh [0]
+
 
-
$ ls -ltr |tail -n 4
+
    Versions:
-
-rw-r--r-- 1 chekh root      27 Nov  7 17:27 test2.do
+
        stata-mp/14.2
-
-rw-r--r-- 1 chekh root      0 Nov  7 17:28 STDIN.o5725
+
        stata-mp/15
-
-rw-r--r-- 1 chekh root      0 Nov  7 17:28 STDIN.e5725
+
        stata-mp/16
-
-rw-r--r-- 1 chekh root    2400 Nov  7 17:28 test2.log
+
...
 +
----------------------------------------------------------------------------
 +
  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>
-
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.
+
==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>):
 +
<pre>
 +
$ module load stata-se
 +
$ which stata-se
 +
/farmshare/software/non-free/stata-se/16/stata-se
 +
$ stata-se
-
==using module==
+
  ___  ____  ____  ____  ____ (R)
-
We're trying to move away from /usr/sweet/bin, using [[FarmShare software | modules]] instead.  So your stata session looks more like:
+
/__    /  ____/  /  ____/
 +
___/  /  /___/  /  /___/  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)
 +
...
 +
</pre>
 +
 
 +
===Desktop Mode===
 +
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:
<pre>
<pre>
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [130]
+
$ ssh -Y sunetid@rice.stanford.edu
-
$ source /mnt/glusterfs/software/free/modules/tcl/init/bash
+
rice $ module load stata-se
-
+(0):WARN:0: Directory '/afs/ir/users/c/h/chekh/.modules' not found
+
rice $ xstata-se &
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
</pre>
-
$ module avail
+
 
-
--------------------- /mnt/glusterfs/software/free/modules/tcl/modulefiles ---------------------
+
==Non-interactive jobs==
-
MATLAB-R2009b    MATLAB-R2011b    R-2.15.0          StatTransfer-11.2 StataSE-12.1     
+
You can also run Stata non-interactively using the <code>do</code> command, producing a <code>.log</code> file containing results:
-
MATLAB-R2010b    MATLAB-R2012a    StatTransfer-10.1 StataMP-12.1     
+
 
-
------------------------------------------- Aliases --------------------------------------------
+
<pre>
-
------------------------------------------- Versions -------------------------------------------
+
$ module load stata-se
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
$ cat test.do
-
$ module load StataSE-12.1
+
sysuse auto
-
[chekh@barley02.stanford.edu] /mnt/glusterfs [0]
+
describe
-
$ stata
+
$ 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>
-
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.
+
===Batch jobs===
 +
Or, submit a batch job to run on one of the compute nodes:
 +
 
 +
<pre>
 +
$ module load stata-se
 +
$ sbatch --wrap='stata -b do test.do'
 +
</pre>
 +
 
 +
You can also write and submit a traditional Slurm job script:
 +
 
 +
<pre>
 +
$ cat test.sh
 +
#!/bin/bash
 +
module load stata-se
 +
stata-se -b do test.do
 +
$ sbatch test.sh
 +
$ ls test.log
 +
test.log
 +
</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