Advertisements

How to Connect SAS with WRDS database (Example Codes!)

Academic researchers are required to work on WRDS database by connecting SAS online. This article explains how to connect SAS with WRDS database. Users can copy the code and use them in their research project.

How to Connect SAS with WRDS database, Connect SAS with WRDS Database.

1. Login to WRDS with SAS

If you want to work on WRDS database using SAS, you should follow the steps below:

Step 1: Define your local library where you will save your works:

option PS=58 LS=72 NODATE NONUMBER;
libname mywt 'C:\wikitekkee\Learning SAS\'; /*Define library where you will save your data */

Step 2: Login to WRDS via SAS:

To login to WRDS via SAS, follow the codes below:

/* Login to WRDS database */ 

%let wrds = wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=WRDS;
signon username=_prompt_;

When you run the above code, you will see the Remote User Identification pop-up to enter your WRDS username and password. After typing the username and password, you are now logged in and ready to define the library.

Remote WRDS User Identification

2. Define Library from WRDS

After successful login, you need to define library of the data table from WRDS. For example:

/* define library */

rsubmit;
options source nocenter ls=72 ps=max;
libname compf '/wrds/comp/sasdata/naa'; /* COMPUSTAT FUNDA*/
libname crspm '/wrds/crsp/sasdata/a_stock'; /*crsp msf*/

Note:

Compustat Annual Funda Library Location

Now you are ready to use these libraries.

3. Collect Customized Variables from WRDS with SAS

To collect data from WRDS, you MUST start your code with “rsubmit“. Then you can write your code. In this example, we use the compf (compustat Fundamental library and want to collect:

rsubmit;
data comp;
set compf.funda (keep=gvkey fyear tic sale ni at act lct lt);
where act is not missing and fyear>1980;
run;

Explanation of the above code:

Advertisements

After running the above the code, you now have a table ‘comp’ on WRDS server. All operation you will perform must start with rsubmit, which indicates that you are working on the WRDS’ server.

The proc print command prints the first 10 observations:

4. Perform Basic Analysis on SAS-Connect

Now, you can perform your analysis. Here is an example:

rsubmit;
data comp;
set comp;
rename tic=ticker;
roi=ni/at;
run;

/* To print the new table with new variable "roi" */
rsubmit;
proc print data=comp (obs=10);
run;

The new table with new variable roi:

SAS-WRDS data analysis

5. Download Data from WRDS to Your Computer

To download the data to your local library, you can use the following code:

rsubmit;
proc download data=comp
out=mywt.comp1;
run;

To work on the downloaded dataset from your local library, you are not required to use rsubmit.

data comp1;
set mywt.comp1;
run;

6. Export Data from SAS to STATA

You can also export your SAS dataset as STATA file, and the code is as follows:

proc export data=comp1
dbms=DTA
outfile="C:\wikitekkee\Learning SAS\comp1.dta"
replace;
run;

7. Connecting STATA with WRDS

To connect python with WRDS, you are required to follow the steps below: And there is a complete tutorial on WRDS and this one.

Once you connect STATA with WRDS, you can see only those tables in which your university or institution subscribes.

8. Connecting Python with WRDS

To connect python, R, MATLAB with WRDS, you can follow posts from WRDS.

WRDS data directory from Python, R, and MATLAB

9. More related readings

Create dataset in SAS

Advertisements

7 Responses

  1. Free Copy of The Essential Keto Cookbook – Limited Availability!

    Hey there,

    Don’t miss out on a FREE copy of The Essential Keto Cookbook, an Amazon Bestseller crafted by my friend Louise.
    Act fast, as she’s giving away only a limited number for free (just cover shipping and handling).

    Over 100 keto recipes
    Burn fat effortlessly
    Boost energy in a week

    Get your free print copy here: https://bit.ly/47n3lyG

    These keto-friendly recipes are 100% delicious, sugar-free, low-carb, gluten-free, grain-free, paleo, dairy-free, and legume-free.

    Grab your cookbook before they run out!
    https://bit.ly/47n3lyG

    Best,
    Keto team,

  2. Hi wikitekkee.com,

    The clock is ticking, and we wanted to give you a heads up – Quick Side Hustle is the key to making holiday debt vanish! Our 1-Click “No-Selling System” is your ticket to earning $208+ per day effortlessly(or drive a lot of traffic to your website), taking advantage of 57+ platforms valued at $142.08 billion dollars.

    Don’t miss out on this golden opportunity. Secure your copy of Quick Side Hustle now before the price increases: https://www.vaulemedia.com/quicksidehustle . Act fast – only 8 out of 99 spots remain! As a special bonus, the first 99 action takers get instant access to the “Copy, Paste, And Profit” upgrade, worth $997. Users are reporting average earnings of $99/hour with this exclusive add-on.

    Time is running out – act now and secure your spot!

    Best regards,
    Anne Maurer

    UNSUBSCRIBE: https://www.vaulemedia.com/unsubscribe
    591 Adamsville Road
    Laredo, TX 78040

  3. The average viewer watches a video for only 12 seconds…this new tech rewards viewers for watching your entire video. GAMIFYING your Youtube video is changing the way companies market.
    As seen on CBS, NBC, FOX, and ABC.

    Shoot me an email or skype msg below to see if you qualify for a free GAMIFICATION of your video.

    Jordan
    email: gamifyvideo@gmail.com
    skype: live:.cid.d347be37995c0a8d

  4. Join the Digital Revolution – for FREE!

    Don’t miss out on this opportunity to upgrade your networking game while making a positive impact on the environment.

    Get your FREE digital business cards today and make lasting connections effortlessly!

    Follow this Secure Link To Transform Your Business @ https://popl.pxf.io/LXLGGa

    #DigitalNetworking#SustainableBusiness#ProfessionalismRedefined#ModernNetworking#GoGreenWithDigitalCards

Leave a Reply

Your email address will not be published. Required fields are marked *

Advertisements