Stata

From ScientificComputing
Jump to: navigation, search

Category

Mathematics, Statistics

Description

Stata is a general-purpose statistical software package created in 1985 by StataCorp. There are four major builds of each version of Stata:
  • Stata/MP for multiprocessor computers (including dual-core and multicore processors)
  • Stata/SE for large databases
  • Stata/IC, which is the standard version
  • Small Stata, which is a smaller, student version for educational purchase only
Stata's capabilities include data management, statistical analysis, graphics, simulations, regression, and custom programming.

Available versions

Legacy versions Supported versions New versions
13, 14

Environment modules

Version Module load command Additional modules loaded automatically
13 module load stata/13
14 module load stata/14

Interactive session

In order to start an interactive Stata session, you need to type the command stata:
[leonhard@euler05 ~]$ module load stata/13
[leonhard@euler05 ~]$ stata

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

x-user Stata network perpetual license:
       Serial number:  xxxxxxxxxxxx
         Licensed to:  xxxx
                       Zurich

Notes:
      1.  Command line editing enabled

Note:  Your site can add messages to the introduction by editing the file
       stata.msg in the directory where Stata is installed.

running /cluster/apps/stata/13/x86_64/sysprofile.do ...
set processors allowed only with Stata/MP.
r(198);

running /cluster/home/leonhard/profile.do ...
set processors allowed only with Stata/MP.
r(198);


. 
You can end the interactive session by typing the command exit. There is also the possibility to use the graphical user interface (GUI) of Stata, if X11-forwarding is already configured. After setting up the X11-forwarding, you can start Stata GUI with the command xstata.

How to submit a job

You can submit a Stata job (my_Stata_script.do) in batch mode with the following command:
bsub [LSF options] "stata -b do my_Stata_script.do"

or in the case of StataMP:

bsub [LSF options] "stata-mp -b do my_parallel_Stata_script.do"
Here you need to replace [LSF options] with LSF parameters for the resource requirements of the job. Please find a documentation about the parameters of bsub on the wiki page about the batch system.

Parallel jobs

If you own a license for running Stata in parallel (StataMP), you can set the number of processors in your Stata input file with the set processor n command to n. Here n has to have the same value as the -n option of bsub

Example

As an example for a Stata job, we are calculating the Euler-Mascheroni constant.
[leonhard@euler02 ~]$ cat test.do 
di %12.10f -digamma(1) 
[leonhard@euler02 ~]$ module load stata/13
[leonhard@euler02 ~]$ bsub -n 1 -W 0:10 -R "rusage[mem=50]" "stata -b do test.do"
Stata job.
Job <30754160> is submitted to queue <normal.4h>.
[leonhard@euler02 ~]$ bjobs
JOBID      USER     STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
30754160   leonhard PEND  normal.4h  euler02                 *o test.do Oct 27 16:31
[leonhard@euler02 ~]$ bjobs
JOBID      USER     STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
30754160   leonhard RUN   normal.4h  euler02     e1245       *o test.do Oct 27 16:31
[leonhard@euler02 ~]$ bjobs
No unfinished job found
[leonhard@euler02 ~]$ grep -A1 digamma test.log 
. di %12.10f -digamma(1)
0.5772156649
Stata does automatically create a log file with the same basename as the input file.

Extensions

The functionality of Stata can be extended by adding more packages. Please find here the instructions on how to install additional Stata packages:
  1. Login to Euler
  2. Load the required modules with: module load new stata/13
  3. Then type stata, to open an interactive Stata session on the command line. Then you can enter all the commands (marked in bold font).
  4. After installing the packages you can type exit to close the interactive Stata session.
[leonhard@euler01 ~]$ module load new stata/13
[leonhard@euler01 ~]$ stata

  ___  ____  ____  ____  ____ (R)
 /__    /   ____/   /   ____/
___/   /   /___/   /   /___/   13.1   Copyright 1985-2013 StataCorp LP
  Statistics/Data Analysis            StataCorp
                                      4905 Lakeway Drive
                                      College Station, Texas 77845 USA
                                      800-STATA-PC        http://www.stata.com
                                      979-696-4600        stata@stata.com
                                      979-696-4601 (fax)
x-user Stata network perpetual license:
       Serial number:  xxxxxxxxxxxx
         Licensed to:  xxxxx
                       Zurich
Notes:
      1.  Command line editing enabled
Note:  Your site can add messages to the introduction by editing the file
       stata.msg in the directory where Stata is installed.
running /cluster/apps/stata/13/x86_64/profile.do ...
set processors allowed only with Stata/MP.
r(198);

. set httpproxyhost proxy.ethz.ch
(set httpproxyhost preference recorded) 

. set httpproxyport 3128
(set httpproxyport preference recorded) 

. set httpproxy on
(set httpproxy preference recorded)

. ssc install estout
checking estout consistency and verifying not already installed...
installing into /cluster/home/leonhard/ado/plus/...
installation complete.

. exit
[leonhard@euler01 ~]$
When you start stata the next time, estadd, estout, estpost, eststo and esttab are available and can be used within .do files or in interactive sessions.

License information

Commercial (Stata SE licenses can be bought through the IT shop). If you would like to use StataMP, then would need to buy the license yourself and provide us a copy of the license agreement.

Notes

Stata is a commercial application, which requires a license. The access to the application is restricted to users that can provide us a copy of the license agreement with the company StataCorp. Please be aware that there are different licenses for the serial and the parallel version of the program. A serial license does not grant you access to the parallel binaries.

Links

http://www.stata.com/

https://en.wikipedia.org/wiki/Stata
https://www.youtube.com/user/statacorp