-
Notifications
You must be signed in to change notification settings - Fork 21
/
pearson_spearman_corr.sas
696 lines (675 loc) · 32.4 KB
/
pearson_spearman_corr.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
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
** Note this is from the Accounting Group Macros.sas file, also included in its entirety;
/*****************************************************
Correlations
Prints matrix of correlations, with Pearson above
the diagonal and Spearman below.
ex: %corrps(dset=mydata, vars=assets earnings return);
*****************************************************/
/**********************************************************************************************/
/* CREATED BY: Steve Stubbin (Stanford) */
/* MODIFIED BY: Scott Dyreng (UNC-Chapel Hill) */
/* DATE CREATED: December 16, 2005 */
/* LAST MODIFIED: March 30, 2006 */
/* MACRO NAME: CORRPS */
/* ARGUMENTS: 1) data=dataset name */
/* 2) vars=variable separated by spaces */
/* DESCRIPTION: This macro computes pearson (above) spearman (below) then diagnol with */
/* corresponding p-values in the column next to the correlation; */
/**********************************************************************************************/
%macro corrps(data=,vars=);
%let i=1;
%let j=1;
%do %until (%SCAN(&vars,&i,%STR( ))=);
%let v&j=%SCAN(&vars,&i,%STR( ));
%let j=%EVAL(&j+2);
%let i=%EVAL(&i+1);
%end;
%let i=1;
%let j=2;
%do %until (%SCAN(&vars,&i,%STR( ))=);
%let v&j=P%SCAN(&vars,&i,%STR( ));
%let j=%EVAL(&j+2);
%let i=%EVAL(&i+1);
%end;
%let nvars=%eval(&i-1);
%macro cor_rep(sta,fin);
%do j=&sta %to &fin;
, (xp.&&v&j + xs.&&v&j) as &&v&j
%end;
%mend;
ods output pearsoncorr=xp spearmancorr=xs;
proc corr data=&data pearson spearman;
var &vars;
run;
data xp;
set xp;
array vars {*} &vars;
do i=1 to (_N_ - 1);
vars(i) = 0;
end;
array vars2 {*} P&vars;
do j=1 to (_N_ - 1);
vars2(j) = 0;
end;
drop i j;
run;
data xs;
set xs;
array vars {*} &vars;
do i=_N_ to &nvars;
vars(i) = 0;
end;
array vars2 {*} P&vars;
do j=_N_ to &nvars;
vars2(j) = 0;
end;
drop i j;
run;
proc sql;
create table xps as
select xp.Variable as VARIABLE %cor_rep(1,&nvars*2)
from xp, xs where (xp.Variable = xs.variable);
quit;
proc print data=xps noobs;
title2 'Pearson (above) / Spearman (below) Correlations';
run;
title2;
proc datasets lib=work nolist;
delete xp xs xps;
run;
quit;
%mend;
%macro ff17(data=,newvarname=industry,sic=sic,out=&data);
data &out;
set &data;
&newvarname = 17;
if 100 <= &sic <= 199 then &newvarname = 17 ;
else if 200 <= &sic <= 299 then &newvarname = 1 ;
else if 700 <= &sic <= 799 then &newvarname = 1 ;
else if 900 <= &sic <= 999 then &newvarname = 1 ;
else if 2000 <= &sic <= 2009 then &newvarname = 1 ;
else if 2010 <= &sic <= 2019 then &newvarname = 1 ;
else if 2020 <= &sic <= 2029 then &newvarname = 1 ;
else if 2030 <= &sic <= 2039 then &newvarname = 1 ;
else if 2040 <= &sic <= 2046 then &newvarname = 1 ;
else if 2047 <= &sic <= 2047 then &newvarname = 1 ;
else if 2048 <= &sic <= 2048 then &newvarname = 1 ;
else if 2050 <= &sic <= 2059 then &newvarname = 1 ;
else if 2060 <= &sic <= 2063 then &newvarname = 1 ;
else if 2064 <= &sic <= 2068 then &newvarname = 1 ;
else if 2070 <= &sic <= 2079 then &newvarname = 1 ;
else if 2080 <= &sic <= 2080 then &newvarname = 1 ;
else if 2082 <= &sic <= 2082 then &newvarname = 1 ;
else if 2083 <= &sic <= 2083 then &newvarname = 1 ;
else if 2084 <= &sic <= 2084 then &newvarname = 1 ;
else if 2085 <= &sic <= 2085 then &newvarname = 1 ;
else if 2086 <= &sic <= 2086 then &newvarname = 1 ;
else if 2087 <= &sic <= 2087 then &newvarname = 1 ;
else if 2090 <= &sic <= 2092 then &newvarname = 1 ;
else if 2095 <= &sic <= 2095 then &newvarname = 1 ;
else if 2096 <= &sic <= 2096 then &newvarname = 1 ;
else if 2097 <= &sic <= 2097 then &newvarname = 1 ;
else if 2098 <= &sic <= 2099 then &newvarname = 1 ;
else if 5140 <= &sic <= 5149 then &newvarname = 1 ;
else if 5150 <= &sic <= 5159 then &newvarname = 1 ;
else if 5180 <= &sic <= 5182 then &newvarname = 1 ;
else if 5191 <= &sic <= 5191 then &newvarname = 1 ;
else if 1000 <= &sic <= 1009 then &newvarname = 2 ;
else if 1010 <= &sic <= 1019 then &newvarname = 2 ;
else if 1020 <= &sic <= 1029 then &newvarname = 2 ;
else if 1030 <= &sic <= 1039 then &newvarname = 2 ;
else if 1040 <= &sic <= 1049 then &newvarname = 2 ;
else if 1060 <= &sic <= 1069 then &newvarname = 2 ;
else if 1080 <= &sic <= 1089 then &newvarname = 2 ;
else if 1090 <= &sic <= 1099 then &newvarname = 2 ;
else if 1200 <= &sic <= 1299 then &newvarname = 2 ;
else if 1400 <= &sic <= 1499 then &newvarname = 2 ;
else if 5050 <= &sic <= 5052 then &newvarname = 2 ;
else if 1300 <= &sic <= 1300 then &newvarname = 3 ;
else if 1310 <= &sic <= 1319 then &newvarname = 3 ;
else if 1320 <= &sic <= 1329 then &newvarname = 3 ;
else if 1380 <= &sic <= 1380 then &newvarname = 3 ;
else if 1381 <= &sic <= 1381 then &newvarname = 3 ;
else if 1382 <= &sic <= 1382 then &newvarname = 3 ;
else if 1389 <= &sic <= 1389 then &newvarname = 3 ;
else if 2900 <= &sic <= 2912 then &newvarname = 3 ;
else if 5170 <= &sic <= 5172 then &newvarname = 3 ;
else if 2200 <= &sic <= 2269 then &newvarname = 4 ;
else if 2270 <= &sic <= 2279 then &newvarname = 4 ;
else if 2280 <= &sic <= 2284 then &newvarname = 4 ;
else if 2290 <= &sic <= 2295 then &newvarname = 4 ;
else if 2296 <= &sic <= 2296 then &newvarname = 4 ;
else if 2297 <= &sic <= 2297 then &newvarname = 4 ;
else if 2298 <= &sic <= 2298 then &newvarname = 4 ;
else if 2299 <= &sic <= 2299 then &newvarname = 4 ;
else if 2300 <= &sic <= 2390 then &newvarname = 4 ;
else if 2391 <= &sic <= 2392 then &newvarname = 4 ;
else if 2393 <= &sic <= 2395 then &newvarname = 4 ;
else if 2396 <= &sic <= 2396 then &newvarname = 4 ;
else if 2397 <= &sic <= 2399 then &newvarname = 4 ;
else if 3020 <= &sic <= 3021 then &newvarname = 4 ;
else if 3100 <= &sic <= 3111 then &newvarname = 4 ;
else if 3130 <= &sic <= 3131 then &newvarname = 4 ;
else if 3140 <= &sic <= 3149 then &newvarname = 4 ;
else if 3150 <= &sic <= 3151 then &newvarname = 4 ;
else if 3963 <= &sic <= 3965 then &newvarname = 4 ;
else if 5130 <= &sic <= 5139 then &newvarname = 4 ;
else if 2510 <= &sic <= 2519 then &newvarname = 5 ;
else if 2590 <= &sic <= 2599 then &newvarname = 5 ;
else if 3060 <= &sic <= 3069 then &newvarname = 5 ;
else if 3070 <= &sic <= 3079 then &newvarname = 5 ;
else if 3080 <= &sic <= 3089 then &newvarname = 5 ;
else if 3090 <= &sic <= 3099 then &newvarname = 5 ;
else if 3630 <= &sic <= 3639 then &newvarname = 5 ;
else if 3650 <= &sic <= 3651 then &newvarname = 5 ;
else if 3652 <= &sic <= 3652 then &newvarname = 5 ;
else if 3860 <= &sic <= 3861 then &newvarname = 5 ;
else if 3870 <= &sic <= 3873 then &newvarname = 5 ;
else if 3910 <= &sic <= 3911 then &newvarname = 5 ;
else if 3914 <= &sic <= 3914 then &newvarname = 5 ;
else if 3915 <= &sic <= 3915 then &newvarname = 5 ;
else if 3930 <= &sic <= 3931 then &newvarname = 5 ;
else if 3940 <= &sic <= 3949 then &newvarname = 5 ;
else if 3960 <= &sic <= 3962 then &newvarname = 5 ;
else if 5020 <= &sic <= 5023 then &newvarname = 5 ;
else if 5064 <= &sic <= 5064 then &newvarname = 5 ;
else if 5094 <= &sic <= 5094 then &newvarname = 5 ;
else if 5099 <= &sic <= 5099 then &newvarname = 5 ;
else if 2800 <= &sic <= 2809 then &newvarname = 6 ;
else if 2810 <= &sic <= 2819 then &newvarname = 6 ;
else if 2820 <= &sic <= 2829 then &newvarname = 6 ;
else if 2860 <= &sic <= 2869 then &newvarname = 6 ;
else if 2870 <= &sic <= 2879 then &newvarname = 6 ;
else if 2890 <= &sic <= 2899 then &newvarname = 6 ;
else if 5160 <= &sic <= 5169 then &newvarname = 6 ;
else if 2100 <= &sic <= 2199 then &newvarname = 7 ;
else if 2830 <= &sic <= 2830 then &newvarname = 7 ;
else if 2831 <= &sic <= 2831 then &newvarname = 7 ;
else if 2833 <= &sic <= 2833 then &newvarname = 7 ;
else if 2834 <= &sic <= 2834 then &newvarname = 7 ;
else if 2840 <= &sic <= 2843 then &newvarname = 7 ;
else if 2844 <= &sic <= 2844 then &newvarname = 7 ;
else if 5120 <= &sic <= 5122 then &newvarname = 7 ;
else if 5194 <= &sic <= 5194 then &newvarname = 7 ;
else if 800 <= &sic <= 899 then &newvarname = 8 ;
else if 1500 <= &sic <= 1511 then &newvarname = 8 ;
else if 1520 <= &sic <= 1529 then &newvarname = 8 ;
else if 1530 <= &sic <= 1539 then &newvarname = 8 ;
else if 1540 <= &sic <= 1549 then &newvarname = 8 ;
else if 1600 <= &sic <= 1699 then &newvarname = 8 ;
else if 1700 <= &sic <= 1799 then &newvarname = 8 ;
else if 2400 <= &sic <= 2439 then &newvarname = 8 ;
else if 2440 <= &sic <= 2449 then &newvarname = 8 ;
else if 2450 <= &sic <= 2459 then &newvarname = 8 ;
else if 2490 <= &sic <= 2499 then &newvarname = 8 ;
else if 2850 <= &sic <= 2859 then &newvarname = 8 ;
else if 2950 <= &sic <= 2952 then &newvarname = 8 ;
else if 3200 <= &sic <= 3200 then &newvarname = 8 ;
else if 3210 <= &sic <= 3211 then &newvarname = 8 ;
else if 3240 <= &sic <= 3241 then &newvarname = 8 ;
else if 3250 <= &sic <= 3259 then &newvarname = 8 ;
else if 3261 <= &sic <= 3261 then &newvarname = 8 ;
else if 3264 <= &sic <= 3264 then &newvarname = 8 ;
else if 3270 <= &sic <= 3275 then &newvarname = 8 ;
else if 3280 <= &sic <= 3281 then &newvarname = 8 ;
else if 3290 <= &sic <= 3293 then &newvarname = 8 ;
else if 3420 <= &sic <= 3429 then &newvarname = 8 ;
else if 3430 <= &sic <= 3433 then &newvarname = 8 ;
else if 3440 <= &sic <= 3441 then &newvarname = 8 ;
else if 3442 <= &sic <= 3442 then &newvarname = 8 ;
else if 3446 <= &sic <= 3446 then &newvarname = 8 ;
else if 3448 <= &sic <= 3448 then &newvarname = 8 ;
else if 3449 <= &sic <= 3449 then &newvarname = 8 ;
else if 3450 <= &sic <= 3451 then &newvarname = 8 ;
else if 3452 <= &sic <= 3452 then &newvarname = 8 ;
else if 5030 <= &sic <= 5039 then &newvarname = 8 ;
else if 5070 <= &sic <= 5078 then &newvarname = 8 ;
else if 5198 <= &sic <= 5198 then &newvarname = 8 ;
else if 5210 <= &sic <= 5211 then &newvarname = 8 ;
else if 5230 <= &sic <= 5231 then &newvarname = 8 ;
else if 5250 <= &sic <= 5251 then &newvarname = 8 ;
else if 3300 <= &sic <= 3300 then &newvarname = 9 ;
else if 3310 <= &sic <= 3317 then &newvarname = 9 ;
else if 3320 <= &sic <= 3325 then &newvarname = 9 ;
else if 3330 <= &sic <= 3339 then &newvarname = 9 ;
else if 3340 <= &sic <= 3341 then &newvarname = 9 ;
else if 3350 <= &sic <= 3357 then &newvarname = 9 ;
else if 3360 <= &sic <= 3369 then &newvarname = 9 ;
else if 3390 <= &sic <= 3399 then &newvarname = 9 ;
else if 3410 <= &sic <= 3412 then &newvarname = 10 ;
else if 3443 <= &sic <= 3443 then &newvarname = 10 ;
else if 3444 <= &sic <= 3444 then &newvarname = 10 ;
else if 3460 <= &sic <= 3469 then &newvarname = 10 ;
else if 3470 <= &sic <= 3479 then &newvarname = 10 ;
else if 3480 <= &sic <= 3489 then &newvarname = 10 ;
else if 3490 <= &sic <= 3499 then &newvarname = 10 ;
else if 3510 <= &sic <= 3519 then &newvarname = 11 ;
else if 3520 <= &sic <= 3529 then &newvarname = 11 ;
else if 3530 <= &sic <= 3530 then &newvarname = 11 ;
else if 3531 <= &sic <= 3531 then &newvarname = 11 ;
else if 3532 <= &sic <= 3532 then &newvarname = 11 ;
else if 3533 <= &sic <= 3533 then &newvarname = 11 ;
else if 3534 <= &sic <= 3534 then &newvarname = 11 ;
else if 3535 <= &sic <= 3535 then &newvarname = 11 ;
else if 3536 <= &sic <= 3536 then &newvarname = 11 ;
else if 3540 <= &sic <= 3549 then &newvarname = 11 ;
else if 3550 <= &sic <= 3559 then &newvarname = 11 ;
else if 3560 <= &sic <= 3569 then &newvarname = 11 ;
else if 3570 <= &sic <= 3579 then &newvarname = 11 ;
else if 3580 <= &sic <= 3580 then &newvarname = 11 ;
else if 3581 <= &sic <= 3581 then &newvarname = 11 ;
else if 3582 <= &sic <= 3582 then &newvarname = 11 ;
else if 3585 <= &sic <= 3585 then &newvarname = 11 ;
else if 3586 <= &sic <= 3586 then &newvarname = 11 ;
else if 3589 <= &sic <= 3589 then &newvarname = 11 ;
else if 3590 <= &sic <= 3599 then &newvarname = 11 ;
else if 3600 <= &sic <= 3600 then &newvarname = 11 ;
else if 3610 <= &sic <= 3613 then &newvarname = 11 ;
else if 3620 <= &sic <= 3621 then &newvarname = 11 ;
else if 3622 <= &sic <= 3622 then &newvarname = 11 ;
else if 3623 <= &sic <= 3629 then &newvarname = 11 ;
else if 3670 <= &sic <= 3679 then &newvarname = 11 ;
else if 3680 <= &sic <= 3680 then &newvarname = 11 ;
else if 3681 <= &sic <= 3681 then &newvarname = 11 ;
else if 3682 <= &sic <= 3682 then &newvarname = 11 ;
else if 3683 <= &sic <= 3683 then &newvarname = 11 ;
else if 3684 <= &sic <= 3684 then &newvarname = 11 ;
else if 3685 <= &sic <= 3685 then &newvarname = 11 ;
else if 3686 <= &sic <= 3686 then &newvarname = 11 ;
else if 3687 <= &sic <= 3687 then &newvarname = 11 ;
else if 3688 <= &sic <= 3688 then &newvarname = 11 ;
else if 3689 <= &sic <= 3689 then &newvarname = 11 ;
else if 3690 <= &sic <= 3690 then &newvarname = 11 ;
else if 3691 <= &sic <= 3692 then &newvarname = 11 ;
else if 3693 <= &sic <= 3693 then &newvarname = 11 ;
else if 3694 <= &sic <= 3694 then &newvarname = 11 ;
else if 3695 <= &sic <= 3695 then &newvarname = 11 ;
else if 3699 <= &sic <= 3699 then &newvarname = 11 ;
else if 3810 <= &sic <= 3810 then &newvarname = 11 ;
else if 3811 <= &sic <= 3811 then &newvarname = 11 ;
else if 3812 <= &sic <= 3812 then &newvarname = 11 ;
else if 3820 <= &sic <= 3820 then &newvarname = 11 ;
else if 3821 <= &sic <= 3821 then &newvarname = 11 ;
else if 3822 <= &sic <= 3822 then &newvarname = 11 ;
else if 3823 <= &sic <= 3823 then &newvarname = 11 ;
else if 3824 <= &sic <= 3824 then &newvarname = 11 ;
else if 3825 <= &sic <= 3825 then &newvarname = 11 ;
else if 3826 <= &sic <= 3826 then &newvarname = 11 ;
else if 3827 <= &sic <= 3827 then &newvarname = 11 ;
else if 3829 <= &sic <= 3829 then &newvarname = 11 ;
else if 3830 <= &sic <= 3839 then &newvarname = 11 ;
else if 3950 <= &sic <= 3955 then &newvarname = 11 ;
else if 5060 <= &sic <= 5060 then &newvarname = 11 ;
else if 5063 <= &sic <= 5063 then &newvarname = 11 ;
else if 5065 <= &sic <= 5065 then &newvarname = 11 ;
else if 5080 <= &sic <= 5080 then &newvarname = 11 ;
else if 5081 <= &sic <= 5081 then &newvarname = 11 ;
else if 3710 <= &sic <= 3710 then &newvarname = 12 ;
else if 3711 <= &sic <= 3711 then &newvarname = 12 ;
else if 3714 <= &sic <= 3714 then &newvarname = 12 ;
else if 3716 <= &sic <= 3716 then &newvarname = 12 ;
else if 3750 <= &sic <= 3751 then &newvarname = 12 ;
else if 3792 <= &sic <= 3792 then &newvarname = 12 ;
else if 5010 <= &sic <= 5015 then &newvarname = 12 ;
else if 5510 <= &sic <= 5521 then &newvarname = 12 ;
else if 5530 <= &sic <= 5531 then &newvarname = 12 ;
else if 5560 <= &sic <= 5561 then &newvarname = 12 ;
else if 5570 <= &sic <= 5571 then &newvarname = 12 ;
else if 5590 <= &sic <= 5599 then &newvarname = 12 ;
else if 3713 <= &sic <= 3713 then &newvarname = 13 ;
else if 3715 <= &sic <= 3715 then &newvarname = 13 ;
else if 3720 <= &sic <= 3720 then &newvarname = 13 ;
else if 3721 <= &sic <= 3721 then &newvarname = 13 ;
else if 3724 <= &sic <= 3724 then &newvarname = 13 ;
else if 3725 <= &sic <= 3725 then &newvarname = 13 ;
else if 3728 <= &sic <= 3728 then &newvarname = 13 ;
else if 3730 <= &sic <= 3731 then &newvarname = 13 ;
else if 3732 <= &sic <= 3732 then &newvarname = 13 ;
else if 3740 <= &sic <= 3743 then &newvarname = 13 ;
else if 3760 <= &sic <= 3769 then &newvarname = 13 ;
else if 3790 <= &sic <= 3790 then &newvarname = 13 ;
else if 3795 <= &sic <= 3795 then &newvarname = 13 ;
else if 3799 <= &sic <= 3799 then &newvarname = 13 ;
else if 4000 <= &sic <= 4013 then &newvarname = 13 ;
else if 4100 <= &sic <= 4100 then &newvarname = 13 ;
else if 4110 <= &sic <= 4119 then &newvarname = 13 ;
else if 4120 <= &sic <= 4121 then &newvarname = 13 ;
else if 4130 <= &sic <= 4131 then &newvarname = 13 ;
else if 4140 <= &sic <= 4142 then &newvarname = 13 ;
else if 4150 <= &sic <= 4151 then &newvarname = 13 ;
else if 4170 <= &sic <= 4173 then &newvarname = 13 ;
else if 4190 <= &sic <= 4199 then &newvarname = 13 ;
else if 4200 <= &sic <= 4200 then &newvarname = 13 ;
else if 4210 <= &sic <= 4219 then &newvarname = 13 ;
else if 4220 <= &sic <= 4229 then &newvarname = 13 ;
else if 4230 <= &sic <= 4231 then &newvarname = 13 ;
else if 4400 <= &sic <= 4499 then &newvarname = 13 ;
else if 4500 <= &sic <= 4599 then &newvarname = 13 ;
else if 4600 <= &sic <= 4699 then &newvarname = 13 ;
else if 4700 <= &sic <= 4700 then &newvarname = 13 ;
else if 4710 <= &sic <= 4712 then &newvarname = 13 ;
else if 4720 <= &sic <= 4729 then &newvarname = 13 ;
else if 4730 <= &sic <= 4739 then &newvarname = 13 ;
else if 4740 <= &sic <= 4742 then &newvarname = 13 ;
else if 4780 <= &sic <= 4780 then &newvarname = 13 ;
else if 4783 <= &sic <= 4783 then &newvarname = 13 ;
else if 4785 <= &sic <= 4785 then &newvarname = 13 ;
else if 4789 <= &sic <= 4789 then &newvarname = 13 ;
else if 4900 <= &sic <= 4900 then &newvarname = 14 ;
else if 4910 <= &sic <= 4911 then &newvarname = 14 ;
else if 4920 <= &sic <= 4922 then &newvarname = 14 ;
else if 4923 <= &sic <= 4923 then &newvarname = 14 ;
else if 4924 <= &sic <= 4925 then &newvarname = 14 ;
else if 4930 <= &sic <= 4931 then &newvarname = 14 ;
else if 4932 <= &sic <= 4932 then &newvarname = 14 ;
else if 4939 <= &sic <= 4939 then &newvarname = 14 ;
else if 4940 <= &sic <= 4942 then &newvarname = 14 ;
else if 5260 <= &sic <= 5261 then &newvarname = 15 ;
else if 5270 <= &sic <= 5271 then &newvarname = 15 ;
else if 5300 <= &sic <= 5300 then &newvarname = 15 ;
else if 5310 <= &sic <= 5311 then &newvarname = 15 ;
else if 5320 <= &sic <= 5320 then &newvarname = 15 ;
else if 5330 <= &sic <= 5331 then &newvarname = 15 ;
else if 5334 <= &sic <= 5334 then &newvarname = 15 ;
else if 5390 <= &sic <= 5399 then &newvarname = 15 ;
else if 5400 <= &sic <= 5400 then &newvarname = 15 ;
else if 5410 <= &sic <= 5411 then &newvarname = 15 ;
else if 5412 <= &sic <= 5412 then &newvarname = 15 ;
else if 5420 <= &sic <= 5421 then &newvarname = 15 ;
else if 5430 <= &sic <= 5431 then &newvarname = 15 ;
else if 5440 <= &sic <= 5441 then &newvarname = 15 ;
else if 5450 <= &sic <= 5451 then &newvarname = 15 ;
else if 5460 <= &sic <= 5461 then &newvarname = 15 ;
else if 5490 <= &sic <= 5499 then &newvarname = 15 ;
else if 5540 <= &sic <= 5541 then &newvarname = 15 ;
else if 5550 <= &sic <= 5551 then &newvarname = 15 ;
else if 5600 <= &sic <= 5699 then &newvarname = 15 ;
else if 5700 <= &sic <= 5700 then &newvarname = 15 ;
else if 5710 <= &sic <= 5719 then &newvarname = 15 ;
else if 5720 <= &sic <= 5722 then &newvarname = 15 ;
else if 5730 <= &sic <= 5733 then &newvarname = 15 ;
else if 5734 <= &sic <= 5734 then &newvarname = 15 ;
else if 5735 <= &sic <= 5735 then &newvarname = 15 ;
else if 5736 <= &sic <= 5736 then &newvarname = 15 ;
else if 5750 <= &sic <= 5750 then &newvarname = 15 ;
else if 5800 <= &sic <= 5813 then &newvarname = 15 ;
else if 5890 <= &sic <= 5890 then &newvarname = 15 ;
else if 5900 <= &sic <= 5900 then &newvarname = 15 ;
else if 5910 <= &sic <= 5912 then &newvarname = 15 ;
else if 5920 <= &sic <= 5921 then &newvarname = 15 ;
else if 5930 <= &sic <= 5932 then &newvarname = 15 ;
else if 5940 <= &sic <= 5940 then &newvarname = 15 ;
else if 5941 <= &sic <= 5941 then &newvarname = 15 ;
else if 5942 <= &sic <= 5942 then &newvarname = 15 ;
else if 5943 <= &sic <= 5943 then &newvarname = 15 ;
else if 5944 <= &sic <= 5944 then &newvarname = 15 ;
else if 5945 <= &sic <= 5945 then &newvarname = 15 ;
else if 5946 <= &sic <= 5946 then &newvarname = 15 ;
else if 5947 <= &sic <= 5947 then &newvarname = 15 ;
else if 5948 <= &sic <= 5948 then &newvarname = 15 ;
else if 5949 <= &sic <= 5949 then &newvarname = 15 ;
else if 5960 <= &sic <= 5963 then &newvarname = 15 ;
else if 5980 <= &sic <= 5989 then &newvarname = 15 ;
else if 5990 <= &sic <= 5990 then &newvarname = 15 ;
else if 5992 <= &sic <= 5992 then &newvarname = 15 ;
else if 5993 <= &sic <= 5993 then &newvarname = 15 ;
else if 5994 <= &sic <= 5994 then &newvarname = 15 ;
else if 5995 <= &sic <= 5995 then &newvarname = 15 ;
else if 5999 <= &sic <= 5999 then &newvarname = 15 ;
else if 6010 <= &sic <= 6019 then &newvarname = 16 ;
else if 6020 <= &sic <= 6020 then &newvarname = 16 ;
else if 6021 <= &sic <= 6021 then &newvarname = 16 ;
else if 6022 <= &sic <= 6022 then &newvarname = 16 ;
else if 6023 <= &sic <= 6023 then &newvarname = 16 ;
else if 6025 <= &sic <= 6025 then &newvarname = 16 ;
else if 6026 <= &sic <= 6026 then &newvarname = 16 ;
else if 6028 <= &sic <= 6029 then &newvarname = 16 ;
else if 6030 <= &sic <= 6036 then &newvarname = 16 ;
else if 6040 <= &sic <= 6049 then &newvarname = 16 ;
else if 6050 <= &sic <= 6059 then &newvarname = 16 ;
else if 6060 <= &sic <= 6062 then &newvarname = 16 ;
else if 6080 <= &sic <= 6082 then &newvarname = 16 ;
else if 6090 <= &sic <= 6099 then &newvarname = 16 ;
else if 6100 <= &sic <= 6100 then &newvarname = 16 ;
else if 6110 <= &sic <= 6111 then &newvarname = 16 ;
else if 6112 <= &sic <= 6112 then &newvarname = 16 ;
else if 6120 <= &sic <= 6129 then &newvarname = 16 ;
else if 6140 <= &sic <= 6149 then &newvarname = 16 ;
else if 6150 <= &sic <= 6159 then &newvarname = 16 ;
else if 6160 <= &sic <= 6163 then &newvarname = 16 ;
else if 6172 <= &sic <= 6172 then &newvarname = 16 ;
else if 6199 <= &sic <= 6199 then &newvarname = 16 ;
else if 6200 <= &sic <= 6299 then &newvarname = 16 ;
else if 6300 <= &sic <= 6300 then &newvarname = 16 ;
else if 6310 <= &sic <= 6312 then &newvarname = 16 ;
else if 6320 <= &sic <= 6324 then &newvarname = 16 ;
else if 6330 <= &sic <= 6331 then &newvarname = 16 ;
else if 6350 <= &sic <= 6351 then &newvarname = 16 ;
else if 6360 <= &sic <= 6361 then &newvarname = 16 ;
else if 6370 <= &sic <= 6371 then &newvarname = 16 ;
else if 6390 <= &sic <= 6399 then &newvarname = 16 ;
else if 6400 <= &sic <= 6411 then &newvarname = 16 ;
else if 6500 <= &sic <= 6500 then &newvarname = 16 ;
else if 6510 <= &sic <= 6510 then &newvarname = 16 ;
else if 6512 <= &sic <= 6512 then &newvarname = 16 ;
else if 6513 <= &sic <= 6513 then &newvarname = 16 ;
else if 6514 <= &sic <= 6514 then &newvarname = 16 ;
else if 6515 <= &sic <= 6515 then &newvarname = 16 ;
else if 6517 <= &sic <= 6519 then &newvarname = 16 ;
else if 6530 <= &sic <= 6531 then &newvarname = 16 ;
else if 6532 <= &sic <= 6532 then &newvarname = 16 ;
else if 6540 <= &sic <= 6541 then &newvarname = 16 ;
else if 6550 <= &sic <= 6553 then &newvarname = 16 ;
else if 6611 <= &sic <= 6611 then &newvarname = 16 ;
else if 6700 <= &sic <= 6700 then &newvarname = 16 ;
else if 6710 <= &sic <= 6719 then &newvarname = 16 ;
else if 6720 <= &sic <= 6722 then &newvarname = 16 ;
else if 6723 <= &sic <= 6723 then &newvarname = 16 ;
else if 6724 <= &sic <= 6724 then &newvarname = 16 ;
else if 6725 <= &sic <= 6725 then &newvarname = 16 ;
else if 6726 <= &sic <= 6726 then &newvarname = 16 ;
else if 6730 <= &sic <= 6733 then &newvarname = 16 ;
else if 6790 <= &sic <= 6790 then &newvarname = 16 ;
else if 6792 <= &sic <= 6792 then &newvarname = 16 ;
else if 6794 <= &sic <= 6794 then &newvarname = 16 ;
else if 6795 <= &sic <= 6795 then &newvarname = 16 ;
else if 6798 <= &sic <= 6798 then &newvarname = 16 ;
else if 6799 <= &sic <= 6799 then &newvarname = 16 ;
else if 2520 <= &sic <= 2549 then &newvarname = 17 ;
else if 2600 <= &sic <= 2639 then &newvarname = 17 ;
else if 2640 <= &sic <= 2659 then &newvarname = 17 ;
else if 2661 <= &sic <= 2661 then &newvarname = 17 ;
else if 2670 <= &sic <= 2699 then &newvarname = 17 ;
else if 2700 <= &sic <= 2709 then &newvarname = 17 ;
else if 2710 <= &sic <= 2719 then &newvarname = 17 ;
else if 2720 <= &sic <= 2729 then &newvarname = 17 ;
else if 2730 <= &sic <= 2739 then &newvarname = 17 ;
else if 2740 <= &sic <= 2749 then &newvarname = 17 ;
else if 2750 <= &sic <= 2759 then &newvarname = 17 ;
else if 2760 <= &sic <= 2761 then &newvarname = 17 ;
else if 2770 <= &sic <= 2771 then &newvarname = 17 ;
else if 2780 <= &sic <= 2789 then &newvarname = 17 ;
else if 2790 <= &sic <= 2799 then &newvarname = 17 ;
else if 2835 <= &sic <= 2835 then &newvarname = 17 ;
else if 2836 <= &sic <= 2836 then &newvarname = 17 ;
else if 2990 <= &sic <= 2999 then &newvarname = 17 ;
else if 3000 <= &sic <= 3000 then &newvarname = 17 ;
else if 3010 <= &sic <= 3011 then &newvarname = 17 ;
else if 3041 <= &sic <= 3041 then &newvarname = 17 ;
else if 3050 <= &sic <= 3053 then &newvarname = 17 ;
else if 3160 <= &sic <= 3161 then &newvarname = 17 ;
else if 3170 <= &sic <= 3171 then &newvarname = 17 ;
else if 3172 <= &sic <= 3172 then &newvarname = 17 ;
else if 3190 <= &sic <= 3199 then &newvarname = 17 ;
else if 3220 <= &sic <= 3221 then &newvarname = 17 ;
else if 3229 <= &sic <= 3229 then &newvarname = 17 ;
else if 3230 <= &sic <= 3231 then &newvarname = 17 ;
else if 3260 <= &sic <= 3260 then &newvarname = 17 ;
else if 3262 <= &sic <= 3263 then &newvarname = 17 ;
else if 3269 <= &sic <= 3269 then &newvarname = 17 ;
else if 3295 <= &sic <= 3299 then &newvarname = 17 ;
else if 3537 <= &sic <= 3537 then &newvarname = 17 ;
else if 3640 <= &sic <= 3644 then &newvarname = 17 ;
else if 3645 <= &sic <= 3645 then &newvarname = 17 ;
else if 3646 <= &sic <= 3646 then &newvarname = 17 ;
else if 3647 <= &sic <= 3647 then &newvarname = 17 ;
else if 3648 <= &sic <= 3649 then &newvarname = 17 ;
else if 3660 <= &sic <= 3660 then &newvarname = 17 ;
else if 3661 <= &sic <= 3661 then &newvarname = 17 ;
else if 3662 <= &sic <= 3662 then &newvarname = 17 ;
else if 3663 <= &sic <= 3663 then &newvarname = 17 ;
else if 3664 <= &sic <= 3664 then &newvarname = 17 ;
else if 3665 <= &sic <= 3665 then &newvarname = 17 ;
else if 3666 <= &sic <= 3666 then &newvarname = 17 ;
else if 3669 <= &sic <= 3669 then &newvarname = 17 ;
else if 3840 <= &sic <= 3849 then &newvarname = 17 ;
else if 3850 <= &sic <= 3851 then &newvarname = 17 ;
else if 3991 <= &sic <= 3991 then &newvarname = 17 ;
else if 3993 <= &sic <= 3993 then &newvarname = 17 ;
else if 3995 <= &sic <= 3995 then &newvarname = 17 ;
else if 3996 <= &sic <= 3996 then &newvarname = 17 ;
else if 4810 <= &sic <= 4813 then &newvarname = 17 ;
else if 4820 <= &sic <= 4822 then &newvarname = 17 ;
else if 4830 <= &sic <= 4839 then &newvarname = 17 ;
else if 4840 <= &sic <= 4841 then &newvarname = 17 ;
else if 4890 <= &sic <= 4890 then &newvarname = 17 ;
else if 4891 <= &sic <= 4891 then &newvarname = 17 ;
else if 4892 <= &sic <= 4892 then &newvarname = 17 ;
else if 4899 <= &sic <= 4899 then &newvarname = 17 ;
else if 4950 <= &sic <= 4959 then &newvarname = 17 ;
else if 4960 <= &sic <= 4961 then &newvarname = 17 ;
else if 4970 <= &sic <= 4971 then &newvarname = 17 ;
else if 4991 <= &sic <= 4991 then &newvarname = 17 ;
else if 5040 <= &sic <= 5042 then &newvarname = 17 ;
else if 5043 <= &sic <= 5043 then &newvarname = 17 ;
else if 5044 <= &sic <= 5044 then &newvarname = 17 ;
else if 5045 <= &sic <= 5045 then &newvarname = 17 ;
else if 5046 <= &sic <= 5046 then &newvarname = 17 ;
else if 5047 <= &sic <= 5047 then &newvarname = 17 ;
else if 5048 <= &sic <= 5048 then &newvarname = 17 ;
else if 5049 <= &sic <= 5049 then &newvarname = 17 ;
else if 5082 <= &sic <= 5082 then &newvarname = 17 ;
else if 5083 <= &sic <= 5083 then &newvarname = 17 ;
else if 5084 <= &sic <= 5084 then &newvarname = 17 ;
else if 5085 <= &sic <= 5085 then &newvarname = 17 ;
else if 5086 <= &sic <= 5087 then &newvarname = 17 ;
else if 5088 <= &sic <= 5088 then &newvarname = 17 ;
else if 5090 <= &sic <= 5090 then &newvarname = 17 ;
else if 5091 <= &sic <= 5092 then &newvarname = 17 ;
else if 5093 <= &sic <= 5093 then &newvarname = 17 ;
else if 5100 <= &sic <= 5100 then &newvarname = 17 ;
else if 5110 <= &sic <= 5113 then &newvarname = 17 ;
else if 5199 <= &sic <= 5199 then &newvarname = 17 ;
else if 7000 <= &sic <= 7000 then &newvarname = 17 ;
else if 7010 <= &sic <= 7011 then &newvarname = 17 ;
else if 7020 <= &sic <= 7021 then &newvarname = 17 ;
else if 7030 <= &sic <= 7033 then &newvarname = 17 ;
else if 7040 <= &sic <= 7041 then &newvarname = 17 ;
else if 7200 <= &sic <= 7200 then &newvarname = 17 ;
else if 7210 <= &sic <= 7212 then &newvarname = 17 ;
else if 7213 <= &sic <= 7213 then &newvarname = 17 ;
else if 7215 <= &sic <= 7216 then &newvarname = 17 ;
else if 7217 <= &sic <= 7217 then &newvarname = 17 ;
else if 7218 <= &sic <= 7218 then &newvarname = 17 ;
else if 7219 <= &sic <= 7219 then &newvarname = 17 ;
else if 7220 <= &sic <= 7221 then &newvarname = 17 ;
else if 7230 <= &sic <= 7231 then &newvarname = 17 ;
else if 7240 <= &sic <= 7241 then &newvarname = 17 ;
else if 7250 <= &sic <= 7251 then &newvarname = 17 ;
else if 7260 <= &sic <= 7269 then &newvarname = 17 ;
else if 7290 <= &sic <= 7290 then &newvarname = 17 ;
else if 7291 <= &sic <= 7291 then &newvarname = 17 ;
else if 7299 <= &sic <= 7299 then &newvarname = 17 ;
else if 7300 <= &sic <= 7300 then &newvarname = 17 ;
else if 7310 <= &sic <= 7319 then &newvarname = 17 ;
else if 7320 <= &sic <= 7323 then &newvarname = 17 ;
else if 7330 <= &sic <= 7338 then &newvarname = 17 ;
else if 7340 <= &sic <= 7342 then &newvarname = 17 ;
else if 7349 <= &sic <= 7349 then &newvarname = 17 ;
else if 7350 <= &sic <= 7351 then &newvarname = 17 ;
else if 7352 <= &sic <= 7352 then &newvarname = 17 ;
else if 7353 <= &sic <= 7353 then &newvarname = 17 ;
else if 7359 <= &sic <= 7359 then &newvarname = 17 ;
else if 7360 <= &sic <= 7369 then &newvarname = 17 ;
else if 7370 <= &sic <= 7372 then &newvarname = 17 ;
else if 7373 <= &sic <= 7373 then &newvarname = 17 ;
else if 7374 <= &sic <= 7374 then &newvarname = 17 ;
else if 7375 <= &sic <= 7375 then &newvarname = 17 ;
else if 7376 <= &sic <= 7376 then &newvarname = 17 ;
else if 7377 <= &sic <= 7377 then &newvarname = 17 ;
else if 7378 <= &sic <= 7378 then &newvarname = 17 ;
else if 7379 <= &sic <= 7379 then &newvarname = 17 ;
else if 7380 <= &sic <= 7380 then &newvarname = 17 ;
else if 7381 <= &sic <= 7382 then &newvarname = 17 ;
else if 7383 <= &sic <= 7383 then &newvarname = 17 ;
else if 7384 <= &sic <= 7384 then &newvarname = 17 ;
else if 7385 <= &sic <= 7385 then &newvarname = 17 ;
else if 7389 <= &sic <= 7390 then &newvarname = 17 ;
else if 7391 <= &sic <= 7391 then &newvarname = 17 ;
else if 7392 <= &sic <= 7392 then &newvarname = 17 ;
else if 7393 <= &sic <= 7393 then &newvarname = 17 ;
else if 7394 <= &sic <= 7394 then &newvarname = 17 ;
else if 7395 <= &sic <= 7395 then &newvarname = 17 ;
else if 7397 <= &sic <= 7397 then &newvarname = 17 ;
else if 7399 <= &sic <= 7399 then &newvarname = 17 ;
else if 7500 <= &sic <= 7500 then &newvarname = 17 ;
else if 7510 <= &sic <= 7519 then &newvarname = 17 ;
else if 7520 <= &sic <= 7523 then &newvarname = 17 ;
else if 7530 <= &sic <= 7539 then &newvarname = 17 ;
else if 7540 <= &sic <= 7549 then &newvarname = 17 ;
else if 7600 <= &sic <= 7600 then &newvarname = 17 ;
else if 7620 <= &sic <= 7620 then &newvarname = 17 ;
else if 7622 <= &sic <= 7622 then &newvarname = 17 ;
else if 7623 <= &sic <= 7623 then &newvarname = 17 ;
else if 7629 <= &sic <= 7629 then &newvarname = 17 ;
else if 7630 <= &sic <= 7631 then &newvarname = 17 ;
else if 7640 <= &sic <= 7641 then &newvarname = 17 ;
else if 7690 <= &sic <= 7699 then &newvarname = 17 ;
else if 7800 <= &sic <= 7829 then &newvarname = 17 ;
else if 7830 <= &sic <= 7833 then &newvarname = 17 ;
else if 7840 <= &sic <= 7841 then &newvarname = 17 ;
else if 7900 <= &sic <= 7900 then &newvarname = 17 ;
else if 7910 <= &sic <= 7911 then &newvarname = 17 ;
else if 7920 <= &sic <= 7929 then &newvarname = 17 ;
else if 7930 <= &sic <= 7933 then &newvarname = 17 ;
else if 7940 <= &sic <= 7949 then &newvarname = 17 ;
else if 7980 <= &sic <= 7980 then &newvarname = 17 ;
else if 7990 <= &sic <= 7999 then &newvarname = 17 ;
else if 8000 <= &sic <= 8099 then &newvarname = 17 ;
else if 8100 <= &sic <= 8199 then &newvarname = 17 ;
else if 8200 <= &sic <= 8299 then &newvarname = 17 ;
else if 8300 <= &sic <= 8399 then &newvarname = 17 ;
else if 8400 <= &sic <= 8499 then &newvarname = 17 ;
else if 8600 <= &sic <= 8699 then &newvarname = 17 ;
else if 8700 <= &sic <= 8700 then &newvarname = 17 ;
else if 8710 <= &sic <= 8713 then &newvarname = 17 ;
else if 8720 <= &sic <= 8721 then &newvarname = 17 ;
else if 8730 <= &sic <= 8734 then &newvarname = 17 ;
else if 8740 <= &sic <= 8748 then &newvarname = 17 ;
else if 8800 <= &sic <= 8899 then &newvarname = 17 ;
else if 8900 <= &sic <= 8910 then &newvarname = 17 ;
else if 8911 <= &sic <= 8911 then &newvarname = 17 ;
else if 8920 <= &sic <= 8999 then &newvarname = 17 ;
else &newvarname = 17;
run;
proc format;
value ff
1 ="Food"
2 ="Mining and Minerals"
3 ="Oil and Petro Products"
4 ="Textiles, Apparel & Footware"
5 ="Consumer Durables"
6 ="Chemicals"
7 ="Drugs, Soap, Prfums, Tobacco"
8 ="Construction"
9 ="Steel"
10 ="Fabricated Products"
11 ="Machinery and Business Equipment"
12 ="Automobiles"
13 ="Transporation"
14 ="Utilities"
15 ="Retail Stores"
16 ="Financial Institutions"
17 ="Other";
run;
%mend;