Extract from Compustat Annual Funda file
Posted: 08 December 2015 07:34 PM   [ Ignore ]
Newbie
Rank
Total Posts:  4
Joined  2015-12-08

Dear All,

I have been trying to use the following code to extract some data from the funda.file, but I’m experiencing some problems.

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

libname mylocal 'C:\Users\Tom\Documents\myfolder'

rsubmit;

libname crspm '/wrds/crsp/sasdata/m_ccm'
libname compa '/wrds/comp/sasdata/naa';

    
/************************************************************************************
* STEP ONE: Extract Compustat data; 
************************************************************************************/

Selected GVKEYS-- use quotes to be consistent with character variables;
%
let glist '006066' '012141'  '014489';   

Date range-- applied to FYEAR (Fiscal Year); 
%
let fyear11960;  
%
let fyear22014;

*  
Selected data items (GVKEYDATADATEFYEAR and FYR are automatialy included);
%
let vars=  gvkey fyr fyear datadate SALE AT INDFMT DATAFMT POPSRC CONSOL;

Make extract from Compustat Annual Funda file;
data compx2;
   
set compa.funda (keep= &vars;);
   
where gvkey in (&glist;) and fyear between &fyear1; and &fyear2;
   if 
indfmt='INDL' and datafmt='STD' and popsrc='D' and consol='C';
   * 
create begin and end dates for fiscal year;
   
format endfyr begfyr date9.;
   
endfyrdatadate;
   
begfyrintnx('month',endfyr,-11,'beg');  /* intnx(interval, from, n, 'aligment') */
   
sxasale/at;  * compute sales over assets ratio;
   
keep gvkey begfyr endfyr sxa fyr fyear;* keep only relevant variables;
run


The code runs smooth and the dataset compx2 is somehow created:

NOTEThere were 153 observations read from the data set COMPA.FUNDAWHERE gvkey in ('006066''012141''014489') and (fyear>=1960 and fyear<=2014);
NOTEThe data set WORK.COMPX2 has 111 observations and 6 variables.
NOTEDATA statement used (Total process time):
      
real time           0.11 seconds
      cpu time            0.04 seconds 

but I’m not able to have access to the folder compx2 just created, as the folder does not appear in the work directory, which is empty.

Any help would be highly appreciated.

Profile
 
 
Posted: 09 December 2015 08:10 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi TomJ,

Try adding the following:

proc download data compx2 out mylocal.a_wrds;run;
endrsubmit

The above code downloads the dataset work.compx2 to your computer (as you have created on the WRDS server). The endrsubmit tells SAS that you are done running code on WRDS (the ‘rsubmit’ and ‘rsubmitend’ indicate that you want to remotely runs a code block).

Best Regards,

Joost

 

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 09 December 2015 08:13 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  4
Joined  2015-12-08

Dear Joost, thanks a lot for your precious help.

It is working now.

Profile
 
 
Posted: 09 December 2015 08:17 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

Good! smile

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 09 December 2015 08:19 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  4
Joined  2015-12-08

May I ask, how could I extend this code to download data about all GVKEYs (and not just 3 as in this toy code). I guess I need a list of the GVKEYs. By any chance, do you know where I could find it?

Thanks again for your patience.

Profile
 
 
Posted: 09 December 2015 08:23 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

sure,

change this line:

where gvkey in (&glist;) and fyear between &fyear1; and &fyear2

to

where fyear between &fyear1; and &fyear2

(forum software adds some semicolons that need to be removed)

This basically removes the filter on gvkey, so you’ll get all gvkeys.

Best,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 09 December 2015 08:30 AM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  4
Joined  2015-12-08

Thanks a lot.

Best,
Tom

Profile
 
 
Posted: 09 December 2015 08:30 AM   [ Ignore ]   [ # 7 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

You’re welcome,

Best,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile