Setting Up Stata in the WRDS Cloud

Learn how to connect to the WRDS Cloud and set up your Stata working environment.

Before You Begin

Before you can work with Stata software and data in the WRDS Cloud, you must have the following:

• A valid, active subscription to any WRDS dataset you wish to use
• A valid, active license for Stata. To obtain a license, see Order Stata
• SSH client software (such as PuTTY) installed on your computer. For more information, see Using SSH to Connect to the WRDS Cloud
• A shell program, such as BASH or TCSH, for accessing the UNIX operating system in the WRDS Cloud

Your WRDS home directory is where you store all your Stata programs and data files. It is located at /home/[your_group name]/[your_username]..

SSH is how you connect to the WRDS Cloud from your computer, and allows you to enter commands and run programs in the WRDS native UNIX environment from a command line window.

If you are unfamiliar with or need to brush up on your UNIX, see UNIX Quick Reference.

Introduction to Stata at WRDS

Stata is an integrated statistical software package popular in various fields of data research, especially in the field of economics.

The following versions of Stata are available in the WRDS Cloud:

• Stata/IC (stata) - the default version for mid-size datasets
• Stata/MP (stata-mp) - for multiprocessor environments, ideal for the WRDS Cloud
• Stata/SE (stata-se) - for large datasets

WRDS recommends the stata-mp version, however there are occasions where the stata or stata-se version may serve you better. For more information, see Which Stata is right for me?

NOTE: The stata-mp version is used for all examples.

Setting Stata Connection Parameters

Using your SSH client, you connect to the WRDS Cloud (see Using SSH to Connect to the WRDS Cloud) and then access data using a secure ODBC connection to a PostgreSQL database.

To connect to the PostgreSQL database, you must first create two files in your WRDS Cloud home directory. This only needs to be done once. Use any text editor, such as UNIX nano or vi, to create these files.

The two files contain the ODBC connection parameters, such as server name, username, and password, so that you do not need to enter them each time you wish to connect to WRDS within Stata.

Once connected, navigate to your home directory and create a new /odbc directory as follows:

To create the odbc directory:

mkdir ~/odbc

While in this new directory, create the first ODBC file as follows and name it odbc.ini.

To create the odbc.ini file:

[ODBC Data Sources]
wrds-postgres = PostgreSQL

[wrds-postgres]
Driver           = PostgreSQL
Description      = Connect to WRDS on the WRDS Cloud
Database         = wrds
Servername       = wrds-pgdata-h.wharton.private
Port             = 9737
SSLmode          = require

As this file contains your WRDS username and password in plain text, it is very important that you restrict permissions on this file using the following command.

This command sets the permissions on this file to be read/write for your user account only.

To restrict file permissions:

chmod 600 ~/odbc/odbc.ini

The second file you need to create depends on what shell your are using - TCSH or BASH. To find out what shell you're running, enter the following from the command prompt:

NOTE: The $HOME variable is expanded to the full path to your home directory when you source this file. Stata requires the full path to be able to properly find the odbc.ini file; using the ~ character as a short cut will not work. For BASH shell users If you are a bash shell user, you will create an odbc.sh file in your ~/odbc/ directory. The file's location should therefore be: ~/odbc/odbc.sh. To create the odbc.sh file for bash users: ODBCINST="/etc/odbcinst.ini"; export ODBCINST ODBCINI="$HOME/odbc/odbc.ini"; export ODBCINI

NOTE: The \$HOME variable is expanded to the full path to your home directory when you source this file. Stata requires the full path to be able to properly find the odbc.ini file; using the ~ character as a short cut will not work.

Next: Running Jobs using Stata

Now that your Stata environment is configured to connect to the WRDS Cloud, you are ready to start Running Jobs using Stata.