Help the Stat Consulting Group by giving a gift

These instructions give tips on installing Stata on Linux. The first set of instructions assume that you are installing the software as a super-user (probably using the "root" account). This is the easiest way to install the software, but is carries some level of risk. Remember that as a super-user, you can delete any files and could possibly remove files or replace files that you did not intend to. Use this method with caution.

The Getting Started Unix manual that comes with Stata has excellent and brief instructions on how to install Stata. We cannot really improve on those instructions, but below we show an example session of installing Stata using those instructions.

Below is a quick rundown of how to install Stata.

1. Insert the Stata CD.

2. Open a terminal window. Make a directory for Stata
and then start the install script from that directory, as shown below.
Note that Stata wants to be installed in **/usr/local **(e.g. /usr/local/stata7).

[root@statlinux root]#mkdir /usr/local/stata7[root@statlinux root]#cd /usr/local/stata7[root@statlinux stata7]#/mnt/cdrom/installStata 7.0 Installation This script installs Stata 7 into the current directory. You will be asked questions and then, once all questions are answered, this script will summarize what it will do for final confirmation. You may press Break at any time up to giving final confirmation. Do you wish to continue? (y/n or q to quit)

Press Y and then the <return> key to continue.

Specify the type of Unix platform on which you are installing Stata 7: 1. IBM AIX 2. DEC Alpha 3. HP-UX 4. Linux for PC 5. Sun Solaris 6. SGI Irix Enter 1, 2, 3, 4, 5, 6, or q to quit:

Press 4 and then the <return> key to continue.

Specify which Stata for PC Linux you wish to install: 1. Stata for PC Linux, dynamically linked (recommended) 2. Stata for PC Linux, statically linked If you make the wrong choice, all that will happen is that later, when you try Stata by typing -xstata- to invoke it, -xstata- will refuse to run and instead produce a large number of error messages. You will then have to install the other Stata by removing this directory and installing again. In our experience, the dynamically linked version works for most users. Enter 1 or 2 or q to quit:

Press 1 and then the <return> key to continue.

About to proceed with installation: To install: Stata for PC Linux, dynamically linked Into directory: /usr/local/stata7 Okay to proceed (y/n or q to quit)

Press Y and then the <return> key to continue.

Copying files ... Stata 7 installation -------------------- 1. uncompressing files 2. extracting libraries 3. setting permissions Done. The next step is to run the license installer. Type: /stinit After that, you will be able to run Intercooled Stata by typing xstata (Run windowed version of Stata) stata (Run console version of Stata) Look at your license. If the licensed software is Stata/SE 7.0 rather than Stata 7.0, you also will be able to run Stata/SE by typing xstata-se (Run windowed version of Stata/SE) stata-se (Run console version of Stata/SE) Make sure /usr/local/stata7 is in your Unix path. Now run ./stinit

Change directories to where Stata is installed and then run stinit as shown below

[root@statlinux stata7]#cd /usr/local/stata7[root@statlinux stata7]#./stinitStata initialization ... You will need the printed LICENSE AND AUTHORIZATION KEY. It has codes which you must enter into the computer to unlock the software. I will verify that the codes you type make sense. I will also ask you for two lines (such as your name and affiliation) and, when I do, you will have plenty of opportunity to verify what you enter is accurate. Do you wish to continue? Type Y or N and press enter: y

Press Y and then the <return> key to continue. Enter your serial number, code and authorization when requested.

Please enter your: Serial number: XXXXXXXXX Code: XXXXXXXXXX Authorization: XXXXXXXXXXX Wait ... Good. The serial number, code, and authorization make sense. Shall we continue? Type Y or N and press enter: y

Press Y and then the <return> key to continue.

------------------------------------------------------------------------------ When Stata comes up, it will display: Serial number XXXXXXXXXXXX licensed to: <something will appear here> <something will appear here> I am about to ask you to fill in those two somethings. These two lines will also be written in certain system files Stata creates so that should you ever send us something on magnetic media, we will know who it is from. If you are the primary user and have a 1- or 2-user license, make the first line your name and the second your affiliation or address. If you have a site license, make the first line the name of your institution or company and the second your city. Shall we continue? Type Y or N and press enter: y

Press Y and then the <return> key to continue. Enter the informtion when prompted.

Enter what you would like the first line to say: XXXXXXXXXXXXXXXXXXXXXXXXXXX Enter what you would like the second line to say: XXXXXXXXXXXXXXXXXXXXXXXXXXX Serial number XXXXXXXXXXXXXXX licensed to: XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX Is this okay? Type Y or N and press enter:

Press Y and then the <return> key to continue.

------------------------------------------------------------------------------ Stata is initialized. You must now, as superuser, enter Stata by typing # ./stata (if you have an Intercooled Stata license) or # ./stata-se (if you have a Stata/SE license) To Stata's dot prompt, type simulinit exit See chapter 1. INSTALLATION in the GETTING STARTED WITH STATA FOR UNIX manual.

Start stata and run **simulinit** as shown below.

[root@statlinux stata7]#./stata___ ____ ____ ____ ____ tm /__ / ____/ / ____/ ___/ / /___/ / /___/ 7.0 Copyright 1984-2002 Statistics/Data Analysis Stata Corporation 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) Single-user Stata for Linux perpetual license: Serial number: XXXXXXXXXXXXXXXX Licensed to: XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX Notes: 1. (-m# option or -set memory-) 1.00 MB allocated to data 2. 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.simulinitfile /usr/local/stata7/.license/stata.sim created

Now, let's get any updates to the current version from Stata.

update all------------------------------------------------------------------------------- > update ado (contacting http://www.stata.com) ... ------------------------------------------------------------------------------- > update executable (contacting http://www.stata.com) Executable update log 1. verifying "/usr/local/stata7/" is writeable 2. downloading new executables New executables successfully downloaded Instructions 1. Exit Stata 2. In Unix, type: $ cd /usr/local/stata7/ $ ./update_stata then choose 1, install update 3. Try Stata If problems, type the same thing, cd followed by update_stata, but this time choose 2, uninstall update 4. If you do not wish to use the automated script, type the same thing and choose 4, do-it-yourself instructionsexit[root@statlinux stata7]#./update_stataChoices: 1. install update 2. uninstall update 3. show overview instructions 4. show do-it-yourself instructions 9. exit Enter your choice:

Press 1 and then the <return> key to continue.

------------------------------------------------------------------------------ Your choice => install update Update successfully installed: previous xstata executable saved as xstata.old previous stata executable saved as stata.old xstata was updated and xstata.bin.Z erased stata was updated and stata.bin.Z erased Try Stata and verify satisfied. Notes: 1. If problems, use -update_stata- to put back the previous executables. 2. If satisfied, you may erase files xstata.old and stata.old, but that is not necessary.

Now make links so everyone can run Stata

[root@statlinux stata7]#cd /usr/local/bin[root@statlinux bin]#ln -s /usr/local/stata7/stata stata[root@statlinux bin]#ln -s /usr/local/stata7/xstata xstata

Reboot linux and Stata should be ready to run.

- Under construction

You can start Stata interactively by typing **stata **or you can
run a Stata program (e.g., myprogram.do) in batch mode in the background by
typing

[root@statlinux ~]#stata -b do myprogram &

For more information on using Stata under Linux, see Getting
Started with Stata
for UNIX. Also see the
Stata FAQs for Unix .

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.