-
Notifications
You must be signed in to change notification settings - Fork 1
/
dissertation-chapter-x-data-creation-barnett-salomon-replication.do
4249 lines (3761 loc) · 181 KB
/
dissertation-chapter-x-data-creation-barnett-salomon-replication.do
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
********************************************************************************
*Title: Dissertation Chapter 2 Barnett and Salomon (2012) Replication and Extension
*Created by: Nicholas Poggioli (poggi005@umn.edu)
*Created on: October 2018
*Purpose: Analyze KLD and CSRHub data
********************************************************************************
/*
***
DATA CREATION AND CLEANING
KLD Data
Compustat Data
CSRHub Data
SAMPLE
Start with KLD 1991-2006
Drop years before 1998 because KLD changed reporting standards (lose 650 firms/4,550 obs)
Merge with COMPUSTAT
Lose 1,236 firms to no match in COMPUSTAT
Final sample
1998 - 2006
1,214 firms
5,944 observations
ANALYSIS SAMPLE
Lose 1,214 obs to lagged DV as independent variable
1,214 firms
4,730 observations
1998 - 2006
VARIABLES
Performance
- ROA = Net Income / Total Assets ($millions)
- Net Income = Earnings after interest, taxes, depreciation, amortization ($millions)
Social Responsibility (proxy for what they call "stakeholder influence capacity"
- Net KLD Score = KLD strengths - KLD concerns
Controls
- Firm size = Number of employees (1000s)
- Debt ratio = Long-term debt / Total assets
- R&D intensity = R&D expenditures / sales
- Advertising intensity = Advertising expenditures / sales
*/
*** CREATE VARIABLES
/*VARIABLES
Performance
- ROA = Net Income / Total Assets ($millions)
- Net Income = Earnings after interest, taxes, depreciation, amortization ($millions)
Social Responsibility (proxy for what they call "stakeholder influence capacity"
- Net KLD Score = KLD strengths - KLD concerns
Controls
- Firm size = Number of employees (1000s)
- Debt ratio = Long-term debt / Total assets
- R&D intensity = R&D expenditures / sales
- Advertising intensity = Advertising expenditures / sales
*/
set more off
***===========================================================***
* Create KLD Data *
* By: Nicholas Poggioli poggi005@umn.edu *
* Date: January 2018 *
* Nicholas Poggioli downloaded all data for all firms *
* from WRDS in February 2017 as kld-all-data.dta *
***===========================================================***
*** IMPORT DATA
use data\all-available-kld-data-from-wrds-downloaded-20180212.dta, clear
*** ORDER AND SORT
rename companyname firm
replace firm=upper(firm)
order firm year ticker, first
sort firm year
*** GENERATE
gen row_id_kld=_n
*** LABEL
foreach var of varlist * {
local lab `: var label `var''
label var `var' "(KLD) `lab'"
}
label var firm "(KLD) Firm name"
label var companyid "(KLD) Company numerical identifier"
label var cusip "(KLD) CUSIP firm identifier (8-digit max length)"
label var ticker "(KLD) Ticker symbol"
label var cgov_str_g "(KLD) Corruption and instability"
label var cgov_str_h "(KLD) Financial system risk"
label var com_str_h "(KLD) Community engagement"
label var div_str_h "(KLD) Employment of underrepresented groups (ended after 2013)"
label var env_str_h "(KLD) Natural resource use - water stress"
label var env_str_i "(KLD) Natural resource use - biodiversity and land use"
label var env_str_j "(KLD) Natural resource use - raw material sourcing"
label var env_str_k "(KLD) Natural resource use - financing environmental impact"
label var env_str_l "(KLD) Environmental opportunities - green buildings"
label var env_str_m "(KLD) Environmental opportunities in renewable energy"
label var env_str_n "(KLD) Waste management - electronic waste"
label var env_str_o "(KLD) Climate change - energy efficiency"
label var env_str_p "(KLD) Climate change - product carbon footprint"
label var env_str_q "(KLD) Climate change - insuring climate change risk"
label var emp_str_i "(KLD) Variable missing from kld data dictionary"
label var emp_str_j "(KLD) Variable missing from kld data dictionary"
label var emp_str_k "(KLD) Variable missing from kld data dictionary"
label var emp_str_l "(KLD) Human capital development"
label var emp_str_n "(KLD) Controversial sourcing (start 2013, previously hum-str-x)"
label var hum_con_h "(KLD) Operations in Sudan"
label var pro_str_d "(KLD) Customer controversies not covered by other rating variables"
label var pro_str_e "(KLD) Social opportunities - access to communications"
label var pro_str_f "(KLD) Social opportunities - opportunities in nutrition and health"
label var pro_str_g "(KLD) Product safety - chemical safety"
label var pro_str_h "(KLD) Product safety - financial product safety"
label var pro_str_i "(KLD) Product safety - privacy and data security"
label var pro_str_j "(KLD) Product safety - responsible investment"
label var pro_str_k "(KLD) Product safety - insuring health and demographic risk"
label var pro_con_g "(KLD) Variable missing from kld data dictionary"
label var row_id_kld "(KLD) Unique ID for each row of data"
***===========================***
* *
* CREATE AGGREGATE VARIABLES *
* *
***===========================***
*** SUMMATION VARIABLES /* The variables included in KLD are wrong */
drop *num
egen sum_alc_con = rowtotal(alc_con_a alc_con_x), missing
egen sum_cgov_con = rowtotal(cgov_con_b cgov_con_f cgov_con_g cgov_con_h cgov_con_i cgov_con_j cgov_con_k cgov_con_l cgov_con_m cgov_con_x), missing
egen sum_cgov_str = rowtotal(cgov_str_a cgov_str_c cgov_str_d cgov_str_e cgov_str_f cgov_str_g cgov_str_h cgov_str_x), missing
egen sum_com_con = rowtotal(com_con_a com_con_b com_con_d com_con_x), missing
egen sum_com_str = rowtotal(com_str_a com_str_b com_str_c com_str_d com_str_f com_str_g com_str_h com_str_x), missing
egen sum_div_con = rowtotal(div_con_a div_con_b div_con_c div_con_d div_con_x), missing
egen sum_div_str = rowtotal(div_str_a div_str_b div_str_c div_str_d div_str_e div_str_f div_str_g div_str_h div_str_x), missing
egen sum_emp_con = rowtotal(emp_con_a emp_con_b emp_con_c emp_con_d emp_con_f emp_con_g emp_con_x), missing
egen sum_emp_str = rowtotal(emp_str_a emp_str_b emp_str_c emp_str_d emp_str_f emp_str_g emp_str_h emp_str_i emp_str_j emp_str_k emp_str_l emp_str_n emp_str_x), missing
egen sum_env_con = rowtotal(env_con_a env_con_b env_con_c env_con_d env_con_e env_con_f env_con_g env_con_h env_con_i env_con_j env_con_k env_con_x), missing
egen sum_env_str = rowtotal(env_str_a env_str_b env_str_c env_str_d env_str_f env_str_g env_str_h env_str_i env_str_j env_str_k env_str_l env_str_m env_str_n env_str_o env_str_p env_str_q env_str_x), missing
egen sum_gam_con = rowtotal(gam_con_a gam_con_x), missing
egen sum_hum_con = rowtotal(hum_con_a hum_con_b hum_con_c hum_con_d hum_con_f hum_con_g hum_con_h hum_con_j hum_con_k hum_con_x), missing
egen sum_hum_str = rowtotal(hum_str_a hum_str_d hum_str_g hum_str_x), missing
egen sum_mil_con = rowtotal(mil_con_a mil_con_b mil_con_c mil_con_x), missing
egen sum_nuc_con = rowtotal(nuc_con_a nuc_con_c nuc_con_d nuc_con_x), missing
egen sum_pro_con = rowtotal(pro_con_a pro_con_d pro_con_e pro_con_f pro_con_g pro_con_x), missing
egen sum_pro_str = rowtotal(pro_str_a pro_str_b pro_str_c pro_str_d pro_str_e pro_str_f pro_str_g pro_str_h pro_str_i pro_str_j pro_str_k pro_str_x), missing
egen sum_tob_con = rowtotal(tob_con_a tob_con_x), missing
label var sum_alc_con "(KLD) Sum of alcohol concerns"
label var sum_cgov_con "(KLD) Sum of corporate governance concerns"
label var sum_cgov_str "(KLD) Sum of corporate governance strengths"
label var sum_com_con "(KLD) Sum of community concerns"
label var sum_com_str "(KLD) Sum of community strengths"
label var sum_div_con "(KLD) Sum of diversity concerns"
label var sum_div_str "(KLD) Sum of diversity strengths"
label var sum_emp_con "(KLD) Sum of employee concerns"
label var sum_emp_str "(KLD) Sum of employee strengths"
label var sum_env_con "(KLD) Sum of environment concerns"
label var sum_env_str "(KLD) Sum of environment strengths"
label var sum_gam_con "(KLD) Sum of gambling concerns"
label var sum_hum_con "(KLD) Sum of human rights concerns"
label var sum_hum_str "(KLD) Sum of human rights strengths"
label var sum_mil_con "(KLD) Sum of military concerns"
label var sum_nuc_con "(KLD) Sum of nuclear concerns"
label var sum_pro_con "(KLD) Sum of product concerns"
label var sum_pro_str "(KLD) Sum of product strengths"
label var sum_tob_con "(KLD) Sum of tobacco concerns"
*** GENERATE
foreach v in cgov com div emp env hum pro {
gen `v'_agg = sum_`v'_str - sum_`v'_con
}
gen alc_agg = sum_alc_con
gen gam_agg = sum_gam_con
gen mil_agg = sum_mil_con
gen nuc_agg = sum_nuc_con
gen tob_agg = sum_tob_con
*** LABEL
label var cgov_agg "(KLD) Aggregate corporate governance"
label var com_agg "(KLD) Aggregate community"
label var div_agg "(KLD) Aggregate diversity"
label var emp_agg "(KLD) Aggregate employee relations"
label var env_agg "(KLD) Aggregate environment"
label var hum_agg "(KLD) Aggregate indigenous peoples relations"
label var pro_agg "(KLD) Aggregate product"
label var alc_agg "(KLD) Aggregate alcohol (no strengths in KLD)"
label var gam_agg "(KLD) Aggregate gambling involvement (no strengths in KLD)"
label var mil_agg "(KLD) Aggregate military involvement (no strengths in KLD)"
label var nuc_agg "(KLD) Aggregate nuclear involvement (no strengths in KLD)"
label var tob_agg "(KLD) Aggregate tobacco invovlement (no strengths in KLD)"
*** GENERATE NET VARIABLES
egen net_kld_str = rowtotal(sum_cgov_str sum_com_str sum_div_str sum_emp_str sum_env_str sum_hum_str sum_pro_str)
egen net_kld_con = rowtotal(sum_alc_con sum_cgov_con sum_com_con sum_div_con sum_emp_con sum_env_con sum_gam_con sum_hum_con sum_mil_con sum_nuc_con sum_pro_con sum_tob_con)
gen net_kld = net_kld_str - net_kld_con
label var net_kld_str "(KLD) Sum of KLD strengths"
label var net_kld_con "(KLD) Sum of KLD concerns"
label var net_kld "(KLD) Net KLD score (strengths - concerns)"
*** CREATE UNIQUE FIRM-YEARS
bysort firm year: gen N=_N
tab N
/*
N | Freq. Percent Cum.
------------+-----------------------------------
1 | 50,762 99.94 99.94
2 | 24 0.05 99.99
4 | 4 0.01 100.00
------------+-----------------------------------
Total | 50,790 100.00
*/
list firm year ticker cusip if N>1, sepby(firm)
/*
+------------------------------------------------------------+
| firm year ticker cusip |
|------------------------------------------------------------|
6107. | BENIHANA INC 2010 82047200 |
6108. | BENIHANA INC 2010 BNHNA 82047101 |
|------------------------------------------------------------|
7293. | BROADWING CORPORATION 2005 BWNG 62878610 |
7294. | BROADWING CORPORATION 2005 BWNG 11161E10 |
|------------------------------------------------------------|
9180. | CENTRAL GARDEN & PET COMPANY 2010 CENT 15352720 |
9181. | CENTRAL GARDEN & PET COMPANY 2010 CENT 15352710 |
|------------------------------------------------------------|
17466. | FIRST BANCORP 2014 FBNC 31891010 |
17467. | FIRST BANCORP 2014 FBP 31867270 |
17468. | FIRST BANCORP 2015 FBNC 31891010 |
17469. | FIRST BANCORP 2015 FBP 31867270 |
|------------------------------------------------------------|
21580. | HEICO CORP. (CL A) 2010 HEI 42280620 |
21581. | HEICO CORP. (CL A) 2010 HEI 42280610 |
|------------------------------------------------------------|
24346. | INVESCO LTD 2007 IVZ_LN 128269 |
24347. | INVESCO LTD 2007 IVZ_LN 46127U10 |
|------------------------------------------------------------|
25515. | KCAP FINANCIAL, INC. 2012 KCAP 50023310 |
25516. | KCAP FINANCIAL, INC. 2012 KCAP 48668E10 |
|------------------------------------------------------------|
37893. | REALOGY CORPORATION 2006 H 36935210 |
37894. | REALOGY CORPORATION 2006 H 41163G10 |
|------------------------------------------------------------|
45900. | TRANSOCEAN SEDCO FOREX, INC. 2000 RIG G9007810 |
45901. | TRANSOCEAN SEDCO FOREX, INC. 2000 RIG CH011117 |
45902. | TRANSOCEAN SEDCO FOREX, INC. 2000 RIG H8817H10 |
45903. | TRANSOCEAN SEDCO FOREX, INC. 2000 RIG G9007310 |
|------------------------------------------------------------|
47276. | UNIVERSAL AMERICAN CORP 2012 UAM 91338E10 |
47277. | UNIVERSAL AMERICAN CORP 2012 UAM 91337710 |
|------------------------------------------------------------|
47541. | URSTADT BIDDLE PROPERTIES, INC. 2010 UBA 91728620 |
47542. | URSTADT BIDDLE PROPERTIES, INC. 2010 UBA 91728610 |
|------------------------------------------------------------|
48216. | VIACOM INC. 2010 VIAB 92553P20 |
48217. | VIACOM INC. 2010 VIA/B 92553P10 |
+------------------------------------------------------------+
*/
drop if N>1
drop N
*** SET PANEL
encode firm, gen(firm_n)
xtset firm_n year, y
*** STANDARDIZE FIRM NAME
*search stnd_compname
stnd_compname firm, gen(stnd_firm entity_type)
gen firm_kld=firm
label var firm_kld "firm name in kld-all-clean.dta"
* Fix observations to prevent duplicate matches later
replace stnd_firm="SPIRE CORP" if stnd_firm=="SPIRE"
* Keep unique stnd_firm
preserve
bysort stnd_firm: gen n=_n
tab n
/*
n | Freq. Percent Cum.
------------+-----------------------------------
1 | 9,680 19.07 19.07
2 | 7,823 15.41 34.48
3 | 4,822 9.50 43.98
4 | 4,168 8.21 52.19
5 | 3,547 6.99 59.18
6 | 3,169 6.24 65.42
7 | 2,809 5.53 70.95
8 | 2,532 4.99 75.94
9 | 2,232 4.40 80.34
10 | 1,910 3.76 84.10
11 | 1,622 3.20 87.30
12 | 1,421 2.80 90.10
13 | 1,237 2.44 92.53
14 | 743 1.46 94.00
15 | 598 1.18 95.18
16 | 393 0.77 95.95
17 | 344 0.68 96.63
18 | 305 0.60 97.23
19 | 272 0.54 97.76
20 | 245 0.48 98.25
21 | 224 0.44 98.69
22 | 187 0.37 99.06
23 | 176 0.35 99.40
24 | 160 0.32 99.72
25 | 143 0.28 100.00
------------+-----------------------------------
Total | 50,762 100.00
*/
keep if n==1
drop n
* Save unique stnd_firm names
keep stnd_firm firm_kld
sort stnd_firm
gen idkld=_n
label var idkld "unique row id for unique stnd_firm in kld data"
compress
save data\unique-stnd_firm-kld-stnd_firm-only.dta, replace
restore
* Save unique cusips to pull cstat data
preserve
bysort cusip: gen n=_n
keep if n==1
drop n
gen len=length(cusip)
tab len
/*
len | Freq. Percent Cum.
------------+-----------------------------------
0 | 1 0.01 0.01
1 | 1 0.01 0.02
2 | 1 0.01 0.03
4 | 1 0.01 0.04
6 | 10 0.11 0.15
7 | 108 1.14 1.28
8 | 9,376 98.72 100.00
------------+-----------------------------------
Total | 9,498 100.00
*/
list stnd_firm year cusip len if len<7, sepby(cusip)
/*
+-------------------------------------------------+
| stnd_firm year cusip len |
|-------------------------------------------------|
1. | EASTMAN KODAK 1991 0 |
|-------------------------------------------------|
2. | CROWN CASTLE INTL 2014 #N/A 4 |
|-------------------------------------------------|
3. | HYPERION THERAPEUTICS 2013 0 1 |
|-------------------------------------------------|
2758. | AAC TECHNOLOGIES HOLDINGS 2013 304105 6 |
|-------------------------------------------------|
3092. | AAON 2012 360206 6 |
|-------------------------------------------------|
3097. | AAR 2006 361105 6 |
|-------------------------------------------------|
3266. | ABB 2013 375204 6 |
|-------------------------------------------------|
3318. | ABCAM PLC 2013 380105 6 |
|-------------------------------------------------|
4555. | ACUSON CORPORTION 2000 511310 6 |
|-------------------------------------------------|
7202. | ACA CAPITAL HOLDINGS 2007 833103 6 |
|-------------------------------------------------|
7804. | ADC TELECOMMUNICATIONS 2000 886101 6 |
|-------------------------------------------------|
7806. | ADC TELECOMMUNICATIONS 2007 886309 6 |
|-------------------------------------------------|
8551. | ABM IND 2011 957100 6 |
|-------------------------------------------------|
9357. | FABRINET 2011 NA 2 |
+-------------------------------------------------+
*/
drop if cusip=="NA"
drop if cusip=="#N/A"
drop if cusip==""
drop if cusip=="0"
drop len
replace cusip = "00" + cusip if len==6
list stnd_firm year cusip len if len<7, sepby(cusip)
/*
+---------------------------------------------------+
| stnd_firm year cusip len |
|---------------------------------------------------|
2755. | AAC TECHNOLOGIES HOLDINGS 2013 00304105 6 |
|---------------------------------------------------|
3089. | AAON 2012 00360206 6 |
|---------------------------------------------------|
3094. | AAR 2006 00361105 6 |
|---------------------------------------------------|
3263. | ABB 2013 00375204 6 |
|---------------------------------------------------|
3315. | ABCAM PLC 2013 00380105 6 |
|---------------------------------------------------|
4552. | ACUSON CORPORTION 2000 00511310 6 |
|---------------------------------------------------|
7199. | ACA CAPITAL HOLDINGS 2007 00833103 6 |
|---------------------------------------------------|
7801. | ADC TELECOMMUNICATIONS 2000 00886101 6 |
|---------------------------------------------------|
7803. | ADC TELECOMMUNICATIONS 2007 00886309 6 |
|---------------------------------------------------|
8548. | ABM IND 2011 00957100 6 |
+---------------------------------------------------+
*/
replace cusip = "0" + cusip if len==7
drop len
gen len=length(cusip)
tab len
/*
len | Freq. Percent Cum.
------------+-----------------------------------
8 | 9,494 100.00 100.00
------------+-----------------------------------
Total | 9,494 100.00
*/
keep cusip
export delimited data/unique-cusips-in-kld.txt, replace novarnames
restore
*** Fix CUSIP length in full data
gen len=length(cusip)
replace cusip = "00" + cusip if len==6
replace cusip = "0" + cusip if len==7
replace cusip="" if len < 6
drop len
*** Export unique CUSIPs
preserve
bysort cusip: gen n=_n
keep if n==1
keep cusip
drop if cusip==""
export delimited "data/unique-8-digits-cusips-in-kld.txt", replace novarnames
restore
*** SAVE
compress
label data "KLD Data 1991 - 2015 downloaded Feb 12, 2018 by poggi005@umn.edu"
save data\kld-all-clean.dta, replace
***===================================================================***
* Create Compustat Data *
* By: Nicholas Poggioli poggi005@umn.edu *
* Compustat Annual Data with variables used in *
* Barnett & Salomon 2012 downloaded from *
* Wharton Research Data Service (WRDS) *
* Data saved as *
* cstat-annual-csrhub-tickers-barnett-salomon-2012-variables.dta *
***===================================================================***
/* No data creation needed because the data were simply downloaded from
WRDS
*/
***===================================================================***
* Create CSRHub Data *
* By: Nicholas Poggioli poggi005@umn.edu *
* Compustat Annual Data with variables used in *
* Barnett & Salomon 2012 downloaded from *
* Wharton Research Data Service (WRDS) *
* Data saved as *
* cstat-annual-csrhub-tickers-barnett-salomon-2012-variables.dta *
***===================================================================***
/* CODE TO CONVERT RAW .CSVS TO STATSETS, LAST RUN MARCH 2, 2018 (LINES 39 - 474)
***===========================================***
* *
* Convert CSRHub .csv files to Stata .dta *
* *
***====================== =====================***
*** CSRHub+Dashboard+CSR_ESG+Research--2017-04-26-OVERALL-ENVIRONMENT-RESOURCEMGMT-RANDOM-FIRMS-ALL
set more off
* a) Load file
import delimited "data/data-csrhub/csrhub-raw/CSRHub+Dashboard+CSR_ESG+Research--2017-04-26 -OVERALL-ENVIRONMENT-RESOURCEMGMT-RANDOM-FIRMS-ALL.csv", ///
varnames(13) rowrange(14) colrange(3) clear
gen row=_n+13
keep if getresultsinthesecells!=""
compress
* b) Rename and label variables with variable names from first row
foreach v of varlist * {
local varlab = `v'[1]
label var `v' "`varlab'"
}
foreach v of varlist getresultsinthesecells v2 v3 {
local varname = `v'[1]
local varname2 = subinstr("`varname'"," ","",.)
rename `v' `varname2'
}
rename CSRHubOfficialName firm
rename v104 industry
rename v105 country
drop v106
foreach v of varlist v4-v103 {
local date = subinstr((subinstr((subinstr(`v'[1],"Overall Rating (","",.)),")","",.))," ","",.)
local varname = "over_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v107-v206 {
local date = subinstr((subinstr((subinstr(`v'[1],"# of Sources Used in Rating (","",.)),")","",.))," ","",.)
local varname = "num_sources`date'"
rename `v' `varname'
}
foreach v of varlist v207-v306 {
local date = subinstr((subinstr((subinstr(`v'[1],"Industry Average Rating (","",.)),")","",.))," ","",.)
local varname = "industry_avg_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v307-v406 {
local date = subinstr((subinstr((subinstr(`v'[1],"Environment Rating (","",.)),")","",.))," ","",.)
local varname = "enviro_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v407-v506 {
local date = subinstr((subinstr((subinstr(`v'[1],"Environment Policy & Reporting Rating (","",.)),")","",.))," ","",.)
local varname = "enviro_pol_rpt_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v507-v606 {
local date = subinstr((subinstr((subinstr(`v'[1],"Resource Management Rating (","",.)),")","",.))," ","",.)
local varname = "resource_mgmt_rtg`date'"
rename `v' `varname'
}
* c) Reshape from wide to long
order industry country, after(ISIN)
drop in 1
bysort firm: gen n=_n
drop if n>1
drop row n
reshape long over_rtg num_sources industry_avg_rtg enviro_rtg ///
enviro_pol_rpt_rtg resource_mgmt_rtg, i(firm) j(date) string
drop if over_rtg=="NA"
compress
*Destring numerics
foreach v of varlist over_rtg num_sources industry_avg_rtg enviro_rtg ///
enviro_pol_rpt_rtg resource_mgmt_rtg {
replace `v'="" if `v'=="NA"
destring `v', replace
}
compress
*Generate date variables
gen datenum=date(date,"MY")
gen month=month(datenum)
gen year=year(datenum)
order datenum, after(date)
*Standardize country to iso3 codes
replace country="Macao" if country=="Macau"
replace country="Korea, Republic of" if country=="South Korea"
replace country="Taiwan, Province of China" if country=="Taiwan"
replace country="United States" if country=="USA"
* d) Save as .dta
gen in_ovrl_enviro=1
compress
save "data/data-csrhub/csrhub-raw/OVERALL-ENVIRO.dta", replace
*** CSRHub+Dashboard+CSR_ESG+Research--2017-04-26-ALL-OTHER-VARIABLES-_________.csv
* a) Load data
set more off
local files : dir "data/data-csrhub/csrhub-raw" files "*all-other*.csv"
display `files'
local n=1
foreach file of local files {
display("`file'")
import delimited "data/data-csrhub/csrhub-raw/`file'", clear ///
varnames(13) rowrange(14) colrange(3)
drop if getresultsinthesecells==""
* b) Rename and label variables with variable names from first row
*Label
foreach v of varlist * {
local varlab = `v'[1]
label var `v' "`varlab'"
}
drop v1404
*Rename
foreach v of varlist getresultsinthesecells v2 v3 {
local varname = `v'[1]
local varname2 = subinstr("`varname'"," ","",.)
rename `v' `varname2'
}
rename CSRHubOfficialName firm
foreach v of varlist v4-v103 {
local date = subinstr((subinstr((subinstr(`v'[1],"Overall Percentile Rank (","",.)),")","",.))," ","",.)
local varname = "over_pct_rank`date'"
rename `v' `varname'
}
foreach v of varlist v104-v203 {
local date = subinstr((subinstr((subinstr(`v'[1],"Community Rating (","",.)),")","",.))," ","",.)
local varname = "cmty_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v204-v303 {
local date = subinstr((subinstr((subinstr(`v'[1],"Employees Rating (","",.)),")","",.))," ","",.)
local varname = "emp_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v304-v403 {
local date = subinstr((subinstr((subinstr(`v'[1],"Governance Rating (","",.)),")","",.))," ","",.)
local varname = "gov_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v404-v503 {
local date = subinstr((subinstr((subinstr(`v'[1],"Community Dev & Philanthropy Rating (","",.)),")","",.))," ","",.)
local varname = "com_dev_phl_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v504-v603 {
local date = subinstr((subinstr((subinstr(`v'[1],"Human Rights & Supply Chain Rating (","",.)),")","",.))," ","",.)
local varname = "humrts_supchain_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v604-v703 {
local date = subinstr((subinstr((subinstr(`v'[1],"Product Rating (","",.)),")","",.))," ","",.)
local varname = "prod_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v704-v803 {
local date = subinstr((subinstr((subinstr(`v'[1],"Compensation & Benefits Rating (","",.)),")","",.))," ","",.)
local varname = "comp_ben_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v804-v903 {
local date = subinstr((subinstr((subinstr(`v'[1],"Diversity & Labor Rights Rating (","",.)),")","",.))," ","",.)
local varname = "div_lab_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v904-v1003 {
local date = subinstr((subinstr((subinstr(`v'[1],"Training, Health & Safety Rating (","",.)),")","",.))," ","",.)
local varname = "train_hlth_safe_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v1004-v1103 {
local date = subinstr((subinstr((subinstr(`v'[1],"Energy & Climate Change Rating (","",.)),")","",.))," ","",.)
local varname = "enrgy_climchge_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v1104-v1203 {
local date = subinstr((subinstr((subinstr(`v'[1],"Board Rating (","",.)),")","",.))," ","",.)
local varname = "board_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v1204-v1303 {
local date = subinstr((subinstr((subinstr(`v'[1],"Leadership Ethics Rating (","",.)),")","",.))," ","",.)
local varname = "ldrship_ethics_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v1304-v1403 {
local date = subinstr((subinstr((subinstr(`v'[1],"Transparency & Reporting Rating (","",.)),")","",.))," ","",.)
local varname = "trans_report_rtg`date'"
rename `v' `varname'
}
* c) Reshape
drop in 1
reshape long over_pct_rank cmty_rtg emp_rtg gov_rtg com_dev_phl_rtg humrts_supchain_rtg ///
prod_rtg comp_ben_rtg div_lab_rtg train_hlth_safe_rtg enrgy_climchge_rtg ///
board_rtg ldrship_ethics_rtg trans_report_rtg, i(firm) j(date) string
*Destring numerics
foreach v of varlist over_pct_rank cmty_rtg emp_rtg gov_rtg com_dev_phl_rtg ///
humrts_supchain_rtg prod_rtg comp_ben_rtg div_lab_rtg train_hlth_safe_rtg ///
enrgy_climchge_rtg board_rtg ldrship_ethics_rtg trans_report_rtg {
replace `v'="" if `v'=="NA"
destring `v', replace
}
gen check = max(over_pct_rank, cmty_rtg, emp_rtg, gov_rtg, com_dev_phl_rtg, humrts_supchain_rtg, prod_rtg, comp_ben_rtg, div_lab_rtg, train_hlth_safe_rtg, enrgy_climchge_rtg, board_rtg, ldrship_ethics_rtg, trans_report_rtg)
drop if check==.
drop check
compress
* d) Append
capt noisily append using `file1'
tempfile file1
save `file1'
}
*Generate date variables
gen datenum=date(date,"MY")
gen month=month(datenum)
gen year=year(datenum)
order datenum, after(date)
* Save unique firm dates
bysort firm date: gen N=_N
tab N
/*. tab N
N | Freq. Percent Cum.
------------+-----------------------------------
1 | 855,620 99.97 99.97
2 | 248 0.03 100.00
------------+-----------------------------------
Total | 855,868 100.00
*/
tab firm if N>1
/*
. tab firm if N>1
CSRHub Official Name | Freq. Percent Cum.
----------------------------------------+-----------------------------------
Embratel Participacoes S.A. | 58 23.39 23.39
RHB Capital Berhad | 190 76.61 100.00
----------------------------------------+-----------------------------------
Total | 248 100.00
*/
bysort firm date: gen n=_n
drop if n>1 /* Appear to have duplicates for all obs of Embratel Participacoes S.A.
and RHB Capital Berhad. Duplicates need to be dropped for merge */
drop N
bysort firm date: gen N=_N
tab N
/*. tab N
N | Freq. Percent Cum.
------------+-----------------------------------
1 | 855,744 100.00 100.00
------------+-----------------------------------
Total | 855,744 100.00
*/
drop n N
* e) Save
gen in_other_vars=1
compress
save "data/data-csrhub/csrhub-raw/OTHER-VARIABLES-ALL.dta", replace
*** CSRHub+Dashboard+CSR_ESG+Research--2017-06-12-updating data from march 2017 to sept 2017-________.csv
clear
set more off
local files : dir "data/data-csrhub/csrhub-raw/" files "*updating data*.csv"
local n=1
foreach file of local files {
display("`file'")
import delimited "data/data-csrhub/csrhub-raw/`file'", clear ///
varnames(13)
* b) Rename and label variables with variable names from first row
*Label
foreach v of varlist * {
local varlab = `v'[1]
label var `v' "`varlab'"
}
*Rename
rename (getresultsinthesecells v4 v5) (firm ticker isin)
drop enteryourdatainthesecells v2
foreach v of varlist v6-v12 {
local date = subinstr((subinstr((subinstr(`v'[1],"Overall Rating (","",.)),")","",.))," ","",.)
local varname = "over_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v13-v19 {
local date = subinstr((subinstr((subinstr(`v'[1],"Overall Percentile Rank (","",.)),")","",.))," ","",.)
local varname = "over_pct_rank`date'"
rename `v' `varname'
}
rename (v20 v21) (industry country)
foreach v of varlist v22-v28 {
local date = subinstr((subinstr((subinstr(`v'[1],"# of Sources Used in Rating (","",.)),")","",.))," ","",.)
local varname = "num_sources`date'"
rename `v' `varname'
}
drop v29-v35
foreach v of varlist v36-v42 {
local date = subinstr((subinstr((subinstr(`v'[1],"Industry Average Rating (","",.)),")","",.))," ","",.)
local varname = "industry_avg_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v43-v49 {
local date = subinstr((subinstr((subinstr(`v'[1],"Employees Rating (","",.)),")","",.))," ","",.)
local varname = "emp_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v50-v56 {
local date = subinstr((subinstr((subinstr(`v'[1],"Environment Rating (","",.)),")","",.))," ","",.)
local varname = "enviro_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v57-v63 {
local date = subinstr((subinstr((subinstr(`v'[1],"Governance Rating (","",.)),")","",.))," ","",.)
local varname = "gov_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v64-v70 {
local date = subinstr((subinstr((subinstr(`v'[1],"Community Dev & Philanthropy Rating (","",.)),")","",.))," ","",.)
local varname = "com_dev_phl_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v71-v77 {
local date = subinstr((subinstr((subinstr(`v'[1],"Human Rights & Supply Chain Rating (","",.)),")","",.))," ","",.)
local varname = "humrts_supchain_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v78-v84 {
local date = subinstr((subinstr((subinstr(`v'[1],"Product Rating (","",.)),")","",.))," ","",.)
local varname = "prod_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v85-v91 {
local date = subinstr((subinstr((subinstr(`v'[1],"Compensation & Benefits Rating (","",.)),")","",.))," ","",.)
local varname = "comp_ben_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v92-v98 {
local date = subinstr((subinstr((subinstr(`v'[1],"Diversity & Labor Rights Rating (","",.)),")","",.))," ","",.)
local varname = "div_lab_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v99-v105 {
local date = subinstr((subinstr((subinstr(`v'[1],"Training, Health & Safety Rating (","",.)),")","",.))," ","",.)
local varname = "train_hlth_safe_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v106-v112 {
local date = subinstr((subinstr((subinstr(`v'[1],"Energy & Climate Change Rating (","",.)),")","",.))," ","",.)
local varname = "enrgy_climchge_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v113-v119 {
local date = subinstr((subinstr((subinstr(`v'[1],"Environment Policy & Reporting Rating (","",.)),")","",.))," ","",.)
local varname = "enviro_pol_rpt_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v120-v126 {
local date = subinstr((subinstr((subinstr(`v'[1],"Resource Management Rating (","",.)),")","",.))," ","",.)
local varname = "resource_mgmt_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v127-v133 {
local date = subinstr((subinstr((subinstr(`v'[1],"Board Rating (","",.)),")","",.))," ","",.)
local varname = "board_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v134-v140 {
local date = subinstr((subinstr((subinstr(`v'[1],"Leadership Ethics Rating (","",.)),")","",.))," ","",.)
local varname = "ldrship_ethics_rtg`date'"
rename `v' `varname'
}
foreach v of varlist v141-v147 {
local date = subinstr((subinstr((subinstr(`v'[1],"Transparency & Reporting Rating (","",.)),")","",.))," ","",.)
local varname = "trans_report_rtg`date'"
rename `v' `varname'
}
* c) Reshape
drop in 1
drop if firm==""
reshape long over_rtg over_pct_rank num_sources industry_avg_rtg emp_rtg ///
enviro_rtg gov_rtg com_dev_phl_rtg humrts_supchain_rtg prod_rtg comp_ben_rtg ///
div_lab_rtg train_hlth_safe_rtg enrgy_climchge_rtg enviro_pol_rpt_rtg ///
resource_mgmt_rtg board_rtg ldrship_ethics_rtg trans_report_rtg, i(firm) j(date) string
*Destring numerics
foreach v of varlist over_rtg over_pct_rank num_sources industry_avg_rtg emp_rtg ///
enviro_rtg gov_rtg com_dev_phl_rtg humrts_supchain_rtg prod_rtg comp_ben_rtg ///
div_lab_rtg train_hlth_safe_rtg enrgy_climchge_rtg enviro_pol_rpt_rtg ///
resource_mgmt_rtg board_rtg ldrship_ethics_rtg trans_report_rtg {
replace `v'="" if `v'=="NA"
destring `v', replace
}
gen check = max(over_rtg , over_pct_rank , industry_avg_rtg , emp_rtg , enviro_rtg , gov_rtg , com_dev_phl_rtg , humrts_supchain_rtg , prod_rtg , comp_ben_rtg , div_lab_rtg , train_hlth_safe_rtg , enrgy_climchge_rtg , enviro_pol_rpt_rtg , resource_mgmt_rtg , board_rtg , ldrship_ethics_rtg , trans_report_rtg)
drop if check==.
drop check
compress
* d) Append
capt noisily append using `file1'
tempfile file1
save `file1'
}
*Generate date variables
gen datenum=date(date,"MY")
gen month=month(datenum)
gen year=year(datenum)
order datenum, after(date)
* Keep unique firm date
bysort firm date: gen N=_N
tab N
/*
N | Freq. Percent Cum.
------------+-----------------------------------
1 | 120,645 99.97 99.97
2 | 42 0.03 100.00
------------+-----------------------------------
Total | 120,687 100.00
*/
bysort firm date: gen n=_n
tab n
/*
n | Freq. Percent Cum.
------------+-----------------------------------
1 | 120,666 99.98 99.98
2 | 21 0.02 100.00
------------+-----------------------------------
Total | 120,687 100.00
*/
/* THESE ALL APPEAR TO BE EXACT DUPLICATES SO I DROP THE DUPLICATES */
drop if n>1
drop N n
* e) Save
gen in_2017_update=1
label var in_2017_update "(CSRHub) =1 if in 2017 data downloaded in early 2018"
compress
save "data/data-csrhub/csrhub-raw/UPDATE-2017.dta", replace
*/
***=========================*
* *
* Merge CSRHub datasets *
* *
***=========================*
* LAST RUN MARCH 9 2018 (LINES 553-794)
set more off
*** OVERALL RATINGS
use data/data-csrhub/csrhub-raw/OVERALL-ENVIRO.DTA, clear