-
Notifications
You must be signed in to change notification settings - Fork 2
/
01-Dataset_import.sas
135 lines (117 loc) · 3.93 KB
/
01-Dataset_import.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*******************************************************************************/
/* */
/* Identifying Firm Life Cycles */
/* */
/* Program : 01-Dataset_import.sas */
/* Author : Attila Balogh, School of Banking and Finance */
/* UNSW Business School, UNSW Sydney */
/* Date Created : 30 Oct 2017 */
/* Last Modified: 30 Oct 2017 */
/* */
/* Description : Calculate additional financial ratios for life cycle */
/* research */
/* */
/* Notes : Please reference the following paper when using this code */
/* Balogh, A, Identifying Firm Life Cycles */
/* Available at SSRN: https://ssrn.com/abstract=xxxxxxx */
/* */
/* This program is to be used in conjunction with prerequisite */
/* programs listed in the 00-Master.sas file */
/*******************************************************************************/
/* Sample dataset to test functionality in the absence of a live input file */
data A_input_00;
informat gvkey $6.;
informat fyear 6.;
format gvkey $6.;
format fyear F6.;
infile datalines;
input gvkey fyear;
return;
datalines;
001690 2010
001690 2011
001690 2012
001690 2013
001690 2014
011974 1998
011974 1999
011974 2000
011974 2001
011974 2002
029028 2010
029028 2011
029028 2012
029028 2013
029028 2014
170617 2010
170617 2011
170617 2012
170617 2013
170617 2014
061143 1993
061143 1994
061143 1995
061143 1996
061143 1997
061143 1998
002136 2005
002136 2006
002136 2007
002136 2008
002136 2009
002136 2010
183920 2005
183920 2006
183920 2007
183920 2008
183920 2009
183920 2010
;
run;
/* Dataset import starts here with a starting dataset named A_input_00 */
/* Creating lagged FYEAR dataset */
data A_input_01;
set A_input_00;
Lfyear = fyear - 1;
drop fyear;
rename Lfyear = fyear;
run;
/* Merging FYEAR and lagged FYEAR datasets */
data A_input_02;
set A_input_00 A_input_01;
run;
/* Removing duplicates for final input dataset */
proc sort data=A_input_02 nodupkey;
by gvkey fyear;
run;
/* Connecting to WRDS to upload query file and obtain */
/* Compustat dataset for the GVKEY-FYEAR combinations */
/* Use this code if you need to connect to WRDS remotely */
/* It first uploads the Input file, matches financial data from comp.funda */
/* and finally downloads the dataset to the local SAS instance */
/*
%let wrds = wrds.wharton.upenn.edu 4016;
options comamid=TCP remote=wrds;
signon username=_prompt_ password=_prompt_;
rsubmit;
proc upload data=A_input_02;
run;
endrsubmit;
*/
proc sql;
create table A_FR_00 as
select a.gvkey as gvkeyA, a.fyear as fyearA, b.*
from A_input_02 a left join compm.funda b
on a.gvkey = b.gvkey and a.fyear = b.fyear;
quit;
/* Use this code if you need to connect to WRDS remotely */
/*
rsubmit;
proc download data=A_FR_00 out=A_FR_00;
run;
endrsubmit;
signoff;
*/
/* *************************************************************************** */
/* ************************* Attila Balogh, 2017 *************************** */
/* *************************************************************************** */