BookmarkSubscribeRSS Feed
Ahmet123
Calcite | Level 5

Hi all, 

 

I'm replicating the work of a paper published in the AER (link here: https://www.aeaweb.org/articles?id=10.1257/aer.96.3.796)

 

It seems like the authors use SAS to download data from WRDS/Compustat. I'm trying to do something similar but my problem is that I can't refer to the data items in compustat. I had to manually download a small sub-sample of the dataset and figure out the naming. It seems that refering to variable names using Dataxxx is standard in compustat. 

 

libname dat '/crds/compustat/sasdata'; 

*this is a dataset downloaded from WRDS and the authors are referencing to the library; 

data a;

set dat.fcab2;

fileid=1;

array data data1-data350;

do over data;

if abs(data-.0001) le .00001

then data=.;

else if abs(data-.0008) le .00001

then data=0;

end;



year=year(date);

year=year-1900;



keep cnum cic dnum year fyr fileid smbl

data1 data2

data147 data148 


aftnt1 aftnt13 aftnt15 aftnt22 aftnt25 aftnt28 aftnt29 

aftnt32 aftnt33 aftnt34 aftnt35 aftnt37 aftnt39 aftnt50

cpspin csspii csspin data308 finc xrel naics spdrc;

 The code that I'm working on is attached. It should be an easy question for someone who already uses this method to access Compustat data. 

 

Thank you very much!! 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Sorry, your problem isn't clear.

Do you have the data?

There is no sas data set that could see on the  provided link, in which case your libname below will not work.

The line 

year=year-1900;

hints of ancient code prone to the Y2K bug.

The attached file points to a sas/connect spawner. Can you connect to it?

Please provide more details.

 

Ahmet123
Calcite | Level 5

Thank you for the reply. 

 

I do not have the data. But I have access to the WRDS (https://wrds-web.wharton.upenn.edu/wrds/index.cfm?) which allows you to create a remote session using SAS. The code is ancient indeed. 

 

I'm really trying to replicate the code to pull the required data from WRDS. 

 

What do you mean SAS/connect spawner? I'm not sure if it is similar to the connection that I've described. 

 

Any further hints would be greatly appreciated! 

 

 

ChrisNZ
Tourmaline | Level 20

> I'm not sure if it is similar to the connection that I've described. 

It is.

 

The code that pulls the data is this:

 

%********************* Connect to server *************;

%let wrds=wrds.wharton.upenn.edu 4016;
options comamid=tcp;
signon wrds username=_prompt_;
 

%********************* Bing back the data *************;

libname NAM "/wrds/comp/sasdata/nam" server=wrds;
data A;  
  set NAM.FUNDA;  
run;

 

Does this work?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2743 views
  • 0 likes
  • 2 in conversation