*****************************************************************************************************************************************************************; * Last Update: June 2011 *; * *; * This SAS code reproduces our main results. *; *****************************************************************************************************************************************************************; libname msf 'C:\Research\CRSP'; *this folder contains one SAS dataset (msf - monthly stock returns file from CRSP); *************************************************; * Assign FF-industries. *; *************************************************; data msf; set msf.msf; by permno date; prc = abs(prc); ask = abs(ASKHI); bid = abs(BIDLO); mprc = abs((ask+bid)/2); if mprc = . then mprc = prc; lCFACPR = lag(CFACPR); lprc = lag(prc); lmprc = lag(mprc); if first.permno then do; lCFACPR=.; lprc=.; lmprc=.; end; adj = lCFACPR/CFACPR; d = -(RETX-RET)*lprc; mret = ((mprc*adj+d)/lmprc)-1; drop lCFACPR lprc lmprc adj d; run; data msf.msf_ind; set msf; if siccd gt 99; if 100 <= SICCD <= 199 then FF30 = 1; else if 200 <= SICCD <= 299 then FF30 = 1; else if 700 <= SICCD <= 799 then FF30 = 1; else if 910 <= SICCD <= 919 then FF30 = 1; else if 2000 <= SICCD <= 2009 then FF30 = 1; else if 2010 <= SICCD <= 2019 then FF30 = 1; else if 2020 <= SICCD <= 2029 then FF30 = 1; else if 2030 <= SICCD <= 2039 then FF30 = 1; else if 2040 <= SICCD <= 2046 then FF30 = 1; else if 2048 <= SICCD <= 2048 then FF30 = 1; else if 2050 <= SICCD <= 2059 then FF30 = 1; else if 2060 <= SICCD <= 2063 then FF30 = 1; else if 2064 <= SICCD <= 2068 then FF30 = 1; else if 2070 <= SICCD <= 2079 then FF30 = 1; else if 2086 <= SICCD <= 2086 then FF30 = 1; else if 2087 <= SICCD <= 2087 then FF30 = 1; else if 2090 <= SICCD <= 2092 then FF30 = 1; else if 2095 <= SICCD <= 2095 then FF30 = 1; else if 2096 <= SICCD <= 2096 then FF30 = 1; else if 2097 <= SICCD <= 2097 then FF30 = 1; else if 2098 <= SICCD <= 2099 then FF30 = 1; else if 2080 <= SICCD <= 2080 then FF30 = 2; else if 2082 <= SICCD <= 2082 then FF30 = 2; else if 2083 <= SICCD <= 2083 then FF30 = 2; else if 2084 <= SICCD <= 2084 then FF30 = 2; else if 2085 <= SICCD <= 2085 then FF30 = 2; else if 2100 <= SICCD <= 2199 then FF30 = 3; else if 920 <= SICCD <= 999 then FF30 = 4; else if 3650 <= SICCD <= 3651 then FF30 = 4; else if 3652 <= SICCD <= 3652 then FF30 = 4; else if 3732 <= SICCD <= 3732 then FF30 = 4; else if 3930 <= SICCD <= 3931 then FF30 = 4; else if 3940 <= SICCD <= 3949 then FF30 = 4; else if 7800 <= SICCD <= 7829 then FF30 = 4; else if 7830 <= SICCD <= 7833 then FF30 = 4; else if 7840 <= SICCD <= 7841 then FF30 = 4; else if 7900 <= SICCD <= 7900 then FF30 = 4; else if 7910 <= SICCD <= 7911 then FF30 = 4; else if 7920 <= SICCD <= 7929 then FF30 = 4; else if 7930 <= SICCD <= 7933 then FF30 = 4; else if 7940 <= SICCD <= 7949 then FF30 = 4; else if 7980 <= SICCD <= 7980 then FF30 = 4; else if 7990 <= SICCD <= 7999 then FF30 = 4; else if 2700 <= SICCD <= 2709 then FF30 = 5; else if 2710 <= SICCD <= 2719 then FF30 = 5; else if 2720 <= SICCD <= 2729 then FF30 = 5; else if 2730 <= SICCD <= 2739 then FF30 = 5; else if 2740 <= SICCD <= 2749 then FF30 = 5; else if 2750 <= SICCD <= 2759 then FF30 = 5; else if 2770 <= SICCD <= 2771 then FF30 = 5; else if 2780 <= SICCD <= 2789 then FF30 = 5; else if 2790 <= SICCD <= 2799 then FF30 = 5; else if 3993 <= SICCD <= 3993 then FF30 = 5; else if 2047 <= SICCD <= 2047 then FF30 = 6; else if 2391 <= SICCD <= 2392 then FF30 = 6; else if 2510 <= SICCD <= 2519 then FF30 = 6; else if 2590 <= SICCD <= 2599 then FF30 = 6; else if 2840 <= SICCD <= 2843 then FF30 = 6; else if 2844 <= SICCD <= 2844 then FF30 = 6; else if 3160 <= SICCD <= 3161 then FF30 = 6; else if 3170 <= SICCD <= 3171 then FF30 = 6; else if 3172 <= SICCD <= 3172 then FF30 = 6; else if 3190 <= SICCD <= 3199 then FF30 = 6; else if 3229 <= SICCD <= 3229 then FF30 = 6; else if 3260 <= SICCD <= 3260 then FF30 = 6; else if 3262 <= SICCD <= 3263 then FF30 = 6; else if 3269 <= SICCD <= 3269 then FF30 = 6; else if 3230 <= SICCD <= 3231 then FF30 = 6; else if 3630 <= SICCD <= 3639 then FF30 = 6; else if 3750 <= SICCD <= 3751 then FF30 = 6; else if 3800 <= SICCD <= 3800 then FF30 = 6; else if 3860 <= SICCD <= 3861 then FF30 = 6; else if 3870 <= SICCD <= 3873 then FF30 = 6; else if 3910 <= SICCD <= 3911 then FF30 = 6; else if 3914 <= SICCD <= 3914 then FF30 = 6; else if 3915 <= SICCD <= 3915 then FF30 = 6; else if 3960 <= SICCD <= 3962 then FF30 = 6; else if 3991 <= SICCD <= 3991 then FF30 = 6; else if 3995 <= SICCD <= 3995 then FF30 = 6; else if 2300 <= SICCD <= 2390 then FF30 = 7; else if 3020 <= SICCD <= 3021 then FF30 = 7; else if 3100 <= SICCD <= 3111 then FF30 = 7; else if 3130 <= SICCD <= 3131 then FF30 = 7; else if 3140 <= SICCD <= 3149 then FF30 = 7; else if 3150 <= SICCD <= 3151 then FF30 = 7; else if 3963 <= SICCD <= 3965 then FF30 = 7; else if 2830 <= SICCD <= 2830 then FF30 = 8; else if 2831 <= SICCD <= 2831 then FF30 = 8; else if 2833 <= SICCD <= 2833 then FF30 = 8; else if 2834 <= SICCD <= 2834 then FF30 = 8; else if 2835 <= SICCD <= 2835 then FF30 = 8; else if 2836 <= SICCD <= 2836 then FF30 = 8; else if 3693 <= SICCD <= 3693 then FF30 = 8; else if 3840 <= SICCD <= 3849 then FF30 = 8; else if 3850 <= SICCD <= 3851 then FF30 = 8; else if 8000 <= SICCD <= 8099 then FF30 = 8; else if 2800 <= SICCD <= 2809 then FF30 = 9; else if 2810 <= SICCD <= 2819 then FF30 = 9; else if 2820 <= SICCD <= 2829 then FF30 = 9; else if 2850 <= SICCD <= 2859 then FF30 = 9; else if 2860 <= SICCD <= 2869 then FF30 = 9; else if 2870 <= SICCD <= 2879 then FF30 = 9; else if 2890 <= SICCD <= 2899 then FF30 = 9; else if 2200 <= SICCD <= 2269 then FF30 = 10; else if 2270 <= SICCD <= 2279 then FF30 = 10; else if 2280 <= SICCD <= 2284 then FF30 = 10; else if 2290 <= SICCD <= 2295 then FF30 = 10; else if 2297 <= SICCD <= 2297 then FF30 = 10; else if 2298 <= SICCD <= 2298 then FF30 = 10; else if 2299 <= SICCD <= 2299 then FF30 = 10; else if 2393 <= SICCD <= 2395 then FF30 = 10; else if 2397 <= SICCD <= 2399 then FF30 = 10; else if 800 <= SICCD <= 899 then FF30 = 11; else if 1500 <= SICCD <= 1511 then FF30 = 11; else if 1520 <= SICCD <= 1529 then FF30 = 11; else if 1530 <= SICCD <= 1539 then FF30 = 11; else if 1540 <= SICCD <= 1549 then FF30 = 11; else if 1600 <= SICCD <= 1699 then FF30 = 11; else if 1700 <= SICCD <= 1799 then FF30 = 11; else if 2400 <= SICCD <= 2439 then FF30 = 11; else if 2450 <= SICCD <= 2459 then FF30 = 11; else if 2490 <= SICCD <= 2499 then FF30 = 11; else if 2660 <= SICCD <= 2661 then FF30 = 11; else if 2950 <= SICCD <= 2952 then FF30 = 11; else if 3200 <= SICCD <= 3200 then FF30 = 11; else if 3210 <= SICCD <= 3211 then FF30 = 11; else if 3240 <= SICCD <= 3241 then FF30 = 11; else if 3250 <= SICCD <= 3259 then FF30 = 11; else if 3261 <= SICCD <= 3261 then FF30 = 11; else if 3264 <= SICCD <= 3264 then FF30 = 11; else if 3270 <= SICCD <= 3275 then FF30 = 11; else if 3280 <= SICCD <= 3281 then FF30 = 11; else if 3290 <= SICCD <= 3293 then FF30 = 11; else if 3295 <= SICCD <= 3299 then FF30 = 11; else if 3420 <= SICCD <= 3429 then FF30 = 11; else if 3430 <= SICCD <= 3433 then FF30 = 11; else if 3440 <= SICCD <= 3441 then FF30 = 11; else if 3442 <= SICCD <= 3442 then FF30 = 11; else if 3446 <= SICCD <= 3446 then FF30 = 11; else if 3448 <= SICCD <= 3448 then FF30 = 11; else if 3449 <= SICCD <= 3449 then FF30 = 11; else if 3450 <= SICCD <= 3451 then FF30 = 11; else if 3452 <= SICCD <= 3452 then FF30 = 11; else if 3490 <= SICCD <= 3499 then FF30 = 11; else if 3996 <= SICCD <= 3996 then FF30 = 11; else if 3300 <= SICCD <= 3300 then FF30 = 12; else if 3310 <= SICCD <= 3317 then FF30 = 12; else if 3320 <= SICCD <= 3325 then FF30 = 12; else if 3330 <= SICCD <= 3339 then FF30 = 12; else if 3340 <= SICCD <= 3341 then FF30 = 12; else if 3350 <= SICCD <= 3357 then FF30 = 12; else if 3360 <= SICCD <= 3369 then FF30 = 12; else if 3370 <= SICCD <= 3379 then FF30 = 12; else if 3390 <= SICCD <= 3399 then FF30 = 12; else if 3400 <= SICCD <= 3400 then FF30 = 13; else if 3443 <= SICCD <= 3443 then FF30 = 13; else if 3444 <= SICCD <= 3444 then FF30 = 13; else if 3460 <= SICCD <= 3469 then FF30 = 13; else if 3470 <= SICCD <= 3479 then FF30 = 13; else if 3510 <= SICCD <= 3519 then FF30 = 13; else if 3520 <= SICCD <= 3529 then FF30 = 13; else if 3530 <= SICCD <= 3530 then FF30 = 13; else if 3531 <= SICCD <= 3531 then FF30 = 13; else if 3532 <= SICCD <= 3532 then FF30 = 13; else if 3533 <= SICCD <= 3533 then FF30 = 13; else if 3534 <= SICCD <= 3534 then FF30 = 13; else if 3535 <= SICCD <= 3535 then FF30 = 13; else if 3536 <= SICCD <= 3536 then FF30 = 13; else if 3538 <= SICCD <= 3538 then FF30 = 13; else if 3540 <= SICCD <= 3549 then FF30 = 13; else if 3550 <= SICCD <= 3559 then FF30 = 13; else if 3560 <= SICCD <= 3569 then FF30 = 13; else if 3580 <= SICCD <= 3580 then FF30 = 13; else if 3581 <= SICCD <= 3581 then FF30 = 13; else if 3582 <= SICCD <= 3582 then FF30 = 13; else if 3585 <= SICCD <= 3585 then FF30 = 13; else if 3586 <= SICCD <= 3586 then FF30 = 13; else if 3589 <= SICCD <= 3589 then FF30 = 13; else if 3590 <= SICCD <= 3599 then FF30 = 13; else if 3600 <= SICCD <= 3600 then FF30 = 14; else if 3610 <= SICCD <= 3613 then FF30 = 14; else if 3620 <= SICCD <= 3621 then FF30 = 14; else if 3623 <= SICCD <= 3629 then FF30 = 14; else if 3640 <= SICCD <= 3644 then FF30 = 14; else if 3645 <= SICCD <= 3645 then FF30 = 14; else if 3646 <= SICCD <= 3646 then FF30 = 14; else if 3648 <= SICCD <= 3649 then FF30 = 14; else if 3660 <= SICCD <= 3660 then FF30 = 14; else if 3690 <= SICCD <= 3690 then FF30 = 14; else if 3691 <= SICCD <= 3692 then FF30 = 14; else if 3699 <= SICCD <= 3699 then FF30 = 14; else if 2296 <= SICCD <= 2296 then FF30 = 15; else if 2396 <= SICCD <= 2396 then FF30 = 15; else if 3010 <= SICCD <= 3011 then FF30 = 15; else if 3537 <= SICCD <= 3537 then FF30 = 15; else if 3647 <= SICCD <= 3647 then FF30 = 15; else if 3694 <= SICCD <= 3694 then FF30 = 15; else if 3700 <= SICCD <= 3700 then FF30 = 15; else if 3710 <= SICCD <= 3710 then FF30 = 15; else if 3711 <= SICCD <= 3711 then FF30 = 15; else if 3713 <= SICCD <= 3713 then FF30 = 15; else if 3714 <= SICCD <= 3714 then FF30 = 15; else if 3715 <= SICCD <= 3715 then FF30 = 15; else if 3716 <= SICCD <= 3716 then FF30 = 15; else if 3792 <= SICCD <= 3792 then FF30 = 15; else if 3790 <= SICCD <= 3791 then FF30 = 15; else if 3799 <= SICCD <= 3799 then FF30 = 15; else if 3720 <= SICCD <= 3720 then FF30 = 16; else if 3721 <= SICCD <= 3721 then FF30 = 16; else if 3723 <= SICCD <= 3724 then FF30 = 16; else if 3725 <= SICCD <= 3725 then FF30 = 16; else if 3728 <= SICCD <= 3729 then FF30 = 16; else if 3730 <= SICCD <= 3731 then FF30 = 16; else if 3740 <= SICCD <= 3743 then FF30 = 16; else if 1000 <= SICCD <= 1009 then FF30 = 17; else if 1010 <= SICCD <= 1019 then FF30 = 17; else if 1020 <= SICCD <= 1029 then FF30 = 17; else if 1030 <= SICCD <= 1039 then FF30 = 17; else if 1040 <= SICCD <= 1049 then FF30 = 17; else if 1050 <= SICCD <= 1059 then FF30 = 17; else if 1060 <= SICCD <= 1069 then FF30 = 17; else if 1070 <= SICCD <= 1079 then FF30 = 17; else if 1080 <= SICCD <= 1089 then FF30 = 17; else if 1090 <= SICCD <= 1099 then FF30 = 17; else if 1100 <= SICCD <= 1119 then FF30 = 17; else if 1400 <= SICCD <= 1499 then FF30 = 17; else if 1200 <= SICCD <= 1299 then FF30 = 18; else if 1300 <= SICCD <= 1300 then FF30 = 19; else if 1310 <= SICCD <= 1319 then FF30 = 19; else if 1320 <= SICCD <= 1329 then FF30 = 19; else if 1330 <= SICCD <= 1339 then FF30 = 19; else if 1370 <= SICCD <= 1379 then FF30 = 19; else if 1380 <= SICCD <= 1380 then FF30 = 19; else if 1381 <= SICCD <= 1381 then FF30 = 19; else if 1382 <= SICCD <= 1382 then FF30 = 19; else if 1389 <= SICCD <= 1389 then FF30 = 19; else if 2900 <= SICCD <= 2912 then FF30 = 19; else if 2990 <= SICCD <= 2999 then FF30 = 19; else if 4900 <= SICCD <= 4900 then FF30 = 20; else if 4910 <= SICCD <= 4911 then FF30 = 20; else if 4920 <= SICCD <= 4922 then FF30 = 20; else if 4923 <= SICCD <= 4923 then FF30 = 20; else if 4924 <= SICCD <= 4925 then FF30 = 20; else if 4930 <= SICCD <= 4931 then FF30 = 20; else if 4932 <= SICCD <= 4932 then FF30 = 20; else if 4939 <= SICCD <= 4939 then FF30 = 20; else if 4940 <= SICCD <= 4942 then FF30 = 20; else if 4800 <= SICCD <= 4800 then FF30 = 21; else if 4810 <= SICCD <= 4813 then FF30 = 21; else if 4820 <= SICCD <= 4822 then FF30 = 21; else if 4830 <= SICCD <= 4839 then FF30 = 21; else if 4840 <= SICCD <= 4841 then FF30 = 21; else if 4880 <= SICCD <= 4889 then FF30 = 21; else if 4890 <= SICCD <= 4890 then FF30 = 21; else if 4891 <= SICCD <= 4891 then FF30 = 21; else if 4892 <= SICCD <= 4892 then FF30 = 21; else if 4899 <= SICCD <= 4899 then FF30 = 21; else if 7020 <= SICCD <= 7021 then FF30 = 22; else if 7030 <= SICCD <= 7033 then FF30 = 22; else if 7200 <= SICCD <= 7200 then FF30 = 22; else if 7210 <= SICCD <= 7212 then FF30 = 22; else if 7214 <= SICCD <= 7214 then FF30 = 22; else if 7215 <= SICCD <= 7216 then FF30 = 22; else if 7217 <= SICCD <= 7217 then FF30 = 22; else if 7218 <= SICCD <= 7218 then FF30 = 22; else if 7219 <= SICCD <= 7219 then FF30 = 22; else if 7220 <= SICCD <= 7221 then FF30 = 22; else if 7230 <= SICCD <= 7231 then FF30 = 22; else if 7240 <= SICCD <= 7241 then FF30 = 22; else if 7250 <= SICCD <= 7251 then FF30 = 22; else if 7260 <= SICCD <= 7269 then FF30 = 22; else if 7270 <= SICCD <= 7290 then FF30 = 22; else if 7291 <= SICCD <= 7291 then FF30 = 22; else if 7292 <= SICCD <= 7299 then FF30 = 22; else if 7300 <= SICCD <= 7300 then FF30 = 22; else if 7310 <= SICCD <= 7319 then FF30 = 22; else if 7320 <= SICCD <= 7329 then FF30 = 22; else if 7330 <= SICCD <= 7339 then FF30 = 22; else if 7340 <= SICCD <= 7342 then FF30 = 22; else if 7349 <= SICCD <= 7349 then FF30 = 22; else if 7350 <= SICCD <= 7351 then FF30 = 22; else if 7352 <= SICCD <= 7352 then FF30 = 22; else if 7353 <= SICCD <= 7353 then FF30 = 22; else if 7359 <= SICCD <= 7359 then FF30 = 22; else if 7360 <= SICCD <= 7369 then FF30 = 22; else if 7370 <= SICCD <= 7372 then FF30 = 22; else if 7374 <= SICCD <= 7374 then FF30 = 22; else if 7375 <= SICCD <= 7375 then FF30 = 22; else if 7376 <= SICCD <= 7376 then FF30 = 22; else if 7377 <= SICCD <= 7377 then FF30 = 22; else if 7378 <= SICCD <= 7378 then FF30 = 22; else if 7379 <= SICCD <= 7379 then FF30 = 22; else if 7380 <= SICCD <= 7380 then FF30 = 22; else if 7381 <= SICCD <= 7382 then FF30 = 22; else if 7383 <= SICCD <= 7383 then FF30 = 22; else if 7384 <= SICCD <= 7384 then FF30 = 22; else if 7385 <= SICCD <= 7385 then FF30 = 22; else if 7389 <= SICCD <= 7390 then FF30 = 22; else if 7391 <= SICCD <= 7391 then FF30 = 22; else if 7392 <= SICCD <= 7392 then FF30 = 22; else if 7393 <= SICCD <= 7393 then FF30 = 22; else if 7394 <= SICCD <= 7394 then FF30 = 22; else if 7395 <= SICCD <= 7395 then FF30 = 22; else if 7396 <= SICCD <= 7396 then FF30 = 22; else if 7397 <= SICCD <= 7397 then FF30 = 22; else if 7399 <= SICCD <= 7399 then FF30 = 22; else if 7500 <= SICCD <= 7500 then FF30 = 22; else if 7510 <= SICCD <= 7519 then FF30 = 22; else if 7520 <= SICCD <= 7529 then FF30 = 22; else if 7530 <= SICCD <= 7539 then FF30 = 22; else if 7540 <= SICCD <= 7549 then FF30 = 22; else if 7600 <= SICCD <= 7600 then FF30 = 22; else if 7620 <= SICCD <= 7620 then FF30 = 22; else if 7622 <= SICCD <= 7622 then FF30 = 22; else if 7623 <= SICCD <= 7623 then FF30 = 22; else if 7629 <= SICCD <= 7629 then FF30 = 22; else if 7630 <= SICCD <= 7631 then FF30 = 22; else if 7640 <= SICCD <= 7641 then FF30 = 22; else if 7690 <= SICCD <= 7699 then FF30 = 22; else if 8100 <= SICCD <= 8199 then FF30 = 22; else if 8200 <= SICCD <= 8299 then FF30 = 22; else if 8300 <= SICCD <= 8399 then FF30 = 22; else if 8400 <= SICCD <= 8499 then FF30 = 22; else if 8600 <= SICCD <= 8699 then FF30 = 22; else if 8700 <= SICCD <= 8700 then FF30 = 22; else if 8710 <= SICCD <= 8713 then FF30 = 22; else if 8720 <= SICCD <= 8721 then FF30 = 22; else if 8730 <= SICCD <= 8734 then FF30 = 22; else if 8740 <= SICCD <= 8748 then FF30 = 22; else if 8800 <= SICCD <= 8899 then FF30 = 22; else if 8900 <= SICCD <= 8910 then FF30 = 22; else if 8911 <= SICCD <= 8911 then FF30 = 22; else if 8920 <= SICCD <= 8999 then FF30 = 22; else if 3570 <= SICCD <= 3579 then FF30 = 23; else if 3622 <= SICCD <= 3622 then FF30 = 23; else if 3661 <= SICCD <= 3661 then FF30 = 23; else if 3662 <= SICCD <= 3662 then FF30 = 23; else if 3663 <= SICCD <= 3663 then FF30 = 23; else if 3664 <= SICCD <= 3664 then FF30 = 23; else if 3665 <= SICCD <= 3665 then FF30 = 23; else if 3666 <= SICCD <= 3666 then FF30 = 23; else if 3669 <= SICCD <= 3669 then FF30 = 23; else if 3670 <= SICCD <= 3679 then FF30 = 23; else if 3680 <= SICCD <= 3680 then FF30 = 23; else if 3681 <= SICCD <= 3681 then FF30 = 23; else if 3682 <= SICCD <= 3682 then FF30 = 23; else if 3683 <= SICCD <= 3683 then FF30 = 23; else if 3684 <= SICCD <= 3684 then FF30 = 23; else if 3685 <= SICCD <= 3685 then FF30 = 23; else if 3686 <= SICCD <= 3686 then FF30 = 23; else if 3687 <= SICCD <= 3687 then FF30 = 23; else if 3688 <= SICCD <= 3688 then FF30 = 23; else if 3689 <= SICCD <= 3689 then FF30 = 23; else if 3695 <= SICCD <= 3695 then FF30 = 23; else if 3810 <= SICCD <= 3810 then FF30 = 23; else if 3811 <= SICCD <= 3811 then FF30 = 23; else if 3812 <= SICCD <= 3812 then FF30 = 23; else if 3820 <= SICCD <= 3820 then FF30 = 23; else if 3821 <= SICCD <= 3821 then FF30 = 23; else if 3822 <= SICCD <= 3822 then FF30 = 23; else if 3823 <= SICCD <= 3823 then FF30 = 23; else if 3824 <= SICCD <= 3824 then FF30 = 23; else if 3825 <= SICCD <= 3825 then FF30 = 23; else if 3826 <= SICCD <= 3826 then FF30 = 23; else if 3827 <= SICCD <= 3827 then FF30 = 23; else if 3829 <= SICCD <= 3829 then FF30 = 23; else if 3830 <= SICCD <= 3839 then FF30 = 23; else if 7373 <= SICCD <= 7373 then FF30 = 23; else if 2440 <= SICCD <= 2449 then FF30 = 24; else if 2520 <= SICCD <= 2549 then FF30 = 24; else if 2600 <= SICCD <= 2639 then FF30 = 24; else if 2640 <= SICCD <= 2659 then FF30 = 24; else if 2670 <= SICCD <= 2699 then FF30 = 24; else if 2760 <= SICCD <= 2761 then FF30 = 24; else if 3220 <= SICCD <= 3221 then FF30 = 24; else if 3410 <= SICCD <= 3412 then FF30 = 24; else if 3950 <= SICCD <= 3955 then FF30 = 24; else if 4000 <= SICCD <= 4013 then FF30 = 25; else if 4040 <= SICCD <= 4049 then FF30 = 25; else if 4100 <= SICCD <= 4100 then FF30 = 25; else if 4110 <= SICCD <= 4119 then FF30 = 25; else if 4120 <= SICCD <= 4121 then FF30 = 25; else if 4130 <= SICCD <= 4131 then FF30 = 25; else if 4140 <= SICCD <= 4142 then FF30 = 25; else if 4150 <= SICCD <= 4151 then FF30 = 25; else if 4170 <= SICCD <= 4173 then FF30 = 25; else if 4190 <= SICCD <= 4199 then FF30 = 25; else if 4200 <= SICCD <= 4200 then FF30 = 25; else if 4210 <= SICCD <= 4219 then FF30 = 25; else if 4220 <= SICCD <= 4229 then FF30 = 25; else if 4230 <= SICCD <= 4231 then FF30 = 25; else if 4240 <= SICCD <= 4249 then FF30 = 25; else if 4400 <= SICCD <= 4499 then FF30 = 25; else if 4500 <= SICCD <= 4599 then FF30 = 25; else if 4600 <= SICCD <= 4699 then FF30 = 25; else if 4700 <= SICCD <= 4700 then FF30 = 25; else if 4710 <= SICCD <= 4712 then FF30 = 25; else if 4720 <= SICCD <= 4729 then FF30 = 25; else if 4730 <= SICCD <= 4739 then FF30 = 25; else if 4740 <= SICCD <= 4749 then FF30 = 25; else if 4780 <= SICCD <= 4780 then FF30 = 25; else if 4782 <= SICCD <= 4782 then FF30 = 25; else if 4783 <= SICCD <= 4783 then FF30 = 25; else if 4784 <= SICCD <= 4784 then FF30 = 25; else if 4785 <= SICCD <= 4785 then FF30 = 25; else if 4789 <= SICCD <= 4789 then FF30 = 25; else if 5000 <= SICCD <= 5000 then FF30 = 26; else if 5010 <= SICCD <= 5015 then FF30 = 26; else if 5020 <= SICCD <= 5023 then FF30 = 26; else if 5030 <= SICCD <= 5039 then FF30 = 26; else if 5040 <= SICCD <= 5042 then FF30 = 26; else if 5043 <= SICCD <= 5043 then FF30 = 26; else if 5044 <= SICCD <= 5044 then FF30 = 26; else if 5045 <= SICCD <= 5045 then FF30 = 26; else if 5046 <= SICCD <= 5046 then FF30 = 26; else if 5047 <= SICCD <= 5047 then FF30 = 26; else if 5048 <= SICCD <= 5048 then FF30 = 26; else if 5049 <= SICCD <= 5049 then FF30 = 26; else if 5050 <= SICCD <= 5059 then FF30 = 26; else if 5060 <= SICCD <= 5060 then FF30 = 26; else if 5063 <= SICCD <= 5063 then FF30 = 26; else if 5064 <= SICCD <= 5064 then FF30 = 26; else if 5065 <= SICCD <= 5065 then FF30 = 26; else if 5070 <= SICCD <= 5078 then FF30 = 26; else if 5080 <= SICCD <= 5080 then FF30 = 26; else if 5081 <= SICCD <= 5081 then FF30 = 26; else if 5082 <= SICCD <= 5082 then FF30 = 26; else if 5083 <= SICCD <= 5083 then FF30 = 26; else if 5084 <= SICCD <= 5084 then FF30 = 26; else if 5085 <= SICCD <= 5085 then FF30 = 26; else if 5086 <= SICCD <= 5087 then FF30 = 26; else if 5088 <= SICCD <= 5088 then FF30 = 26; else if 5090 <= SICCD <= 5090 then FF30 = 26; else if 5091 <= SICCD <= 5092 then FF30 = 26; else if 5093 <= SICCD <= 5093 then FF30 = 26; else if 5094 <= SICCD <= 5094 then FF30 = 26; else if 5099 <= SICCD <= 5099 then FF30 = 26; else if 5100 <= SICCD <= 5100 then FF30 = 26; else if 5110 <= SICCD <= 5113 then FF30 = 26; else if 5120 <= SICCD <= 5122 then FF30 = 26; else if 5130 <= SICCD <= 5139 then FF30 = 26; else if 5140 <= SICCD <= 5149 then FF30 = 26; else if 5150 <= SICCD <= 5159 then FF30 = 26; else if 5160 <= SICCD <= 5169 then FF30 = 26; else if 5170 <= SICCD <= 5172 then FF30 = 26; else if 5180 <= SICCD <= 5182 then FF30 = 26; else if 5190 <= SICCD <= 5199 then FF30 = 26; else if 5200 <= SICCD <= 5200 then FF30 = 27; else if 5210 <= SICCD <= 5219 then FF30 = 27; else if 5220 <= SICCD <= 5229 then FF30 = 27; else if 5230 <= SICCD <= 5231 then FF30 = 27; else if 5250 <= SICCD <= 5251 then FF30 = 27; else if 5260 <= SICCD <= 5261 then FF30 = 27; else if 5270 <= SICCD <= 5271 then FF30 = 27; else if 5300 <= SICCD <= 5300 then FF30 = 27; else if 5310 <= SICCD <= 5311 then FF30 = 27; else if 5320 <= SICCD <= 5320 then FF30 = 27; else if 5330 <= SICCD <= 5331 then FF30 = 27; else if 5334 <= SICCD <= 5334 then FF30 = 27; else if 5340 <= SICCD <= 5349 then FF30 = 27; else if 5390 <= SICCD <= 5399 then FF30 = 27; else if 5400 <= SICCD <= 5400 then FF30 = 27; else if 5410 <= SICCD <= 5411 then FF30 = 27; else if 5412 <= SICCD <= 5412 then FF30 = 27; else if 5420 <= SICCD <= 5429 then FF30 = 27; else if 5430 <= SICCD <= 5439 then FF30 = 27; else if 5440 <= SICCD <= 5449 then FF30 = 27; else if 5450 <= SICCD <= 5459 then FF30 = 27; else if 5460 <= SICCD <= 5469 then FF30 = 27; else if 5490 <= SICCD <= 5499 then FF30 = 27; else if 5500 <= SICCD <= 5500 then FF30 = 27; else if 5510 <= SICCD <= 5529 then FF30 = 27; else if 5530 <= SICCD <= 5539 then FF30 = 27; else if 5540 <= SICCD <= 5549 then FF30 = 27; else if 5550 <= SICCD <= 5559 then FF30 = 27; else if 5560 <= SICCD <= 5569 then FF30 = 27; else if 5570 <= SICCD <= 5579 then FF30 = 27; else if 5590 <= SICCD <= 5599 then FF30 = 27; else if 5600 <= SICCD <= 5699 then FF30 = 27; else if 5700 <= SICCD <= 5700 then FF30 = 27; else if 5710 <= SICCD <= 5719 then FF30 = 27; else if 5720 <= SICCD <= 5722 then FF30 = 27; else if 5730 <= SICCD <= 5733 then FF30 = 27; else if 5734 <= SICCD <= 5734 then FF30 = 27; else if 5735 <= SICCD <= 5735 then FF30 = 27; else if 5736 <= SICCD <= 5736 then FF30 = 27; else if 5750 <= SICCD <= 5799 then FF30 = 27; else if 5900 <= SICCD <= 5900 then FF30 = 27; else if 5910 <= SICCD <= 5912 then FF30 = 27; else if 5920 <= SICCD <= 5929 then FF30 = 27; else if 5930 <= SICCD <= 5932 then FF30 = 27; else if 5940 <= SICCD <= 5940 then FF30 = 27; else if 5941 <= SICCD <= 5941 then FF30 = 27; else if 5942 <= SICCD <= 5942 then FF30 = 27; else if 5943 <= SICCD <= 5943 then FF30 = 27; else if 5944 <= SICCD <= 5944 then FF30 = 27; else if 5945 <= SICCD <= 5945 then FF30 = 27; else if 5946 <= SICCD <= 5946 then FF30 = 27; else if 5947 <= SICCD <= 5947 then FF30 = 27; else if 5948 <= SICCD <= 5948 then FF30 = 27; else if 5949 <= SICCD <= 5949 then FF30 = 27; else if 5950 <= SICCD <= 5959 then FF30 = 27; else if 5960 <= SICCD <= 5969 then FF30 = 27; else if 5970 <= SICCD <= 5979 then FF30 = 27; else if 5980 <= SICCD <= 5989 then FF30 = 27; else if 5990 <= SICCD <= 5990 then FF30 = 27; else if 5992 <= SICCD <= 5992 then FF30 = 27; else if 5993 <= SICCD <= 5993 then FF30 = 27; else if 5994 <= SICCD <= 5994 then FF30 = 27; else if 5995 <= SICCD <= 5995 then FF30 = 27; else if 5999 <= SICCD <= 5999 then FF30 = 27; else if 5800 <= SICCD <= 5819 then FF30 = 28; else if 5820 <= SICCD <= 5829 then FF30 = 28; else if 5890 <= SICCD <= 5899 then FF30 = 28; else if 7000 <= SICCD <= 7000 then FF30 = 28; else if 7010 <= SICCD <= 7019 then FF30 = 28; else if 7040 <= SICCD <= 7049 then FF30 = 28; else if 7213 <= SICCD <= 7213 then FF30 = 28; else if 6000 <= SICCD <= 6000 then FF30 = 29; else if 6010 <= SICCD <= 6019 then FF30 = 29; else if 6020 <= SICCD <= 6020 then FF30 = 29; else if 6021 <= SICCD <= 6021 then FF30 = 29; else if 6022 <= SICCD <= 6022 then FF30 = 29; else if 6023 <= SICCD <= 6024 then FF30 = 29; else if 6025 <= SICCD <= 6025 then FF30 = 29; else if 6026 <= SICCD <= 6026 then FF30 = 29; else if 6027 <= SICCD <= 6027 then FF30 = 29; else if 6028 <= SICCD <= 6029 then FF30 = 29; else if 6030 <= SICCD <= 6036 then FF30 = 29; else if 6040 <= SICCD <= 6059 then FF30 = 29; else if 6060 <= SICCD <= 6062 then FF30 = 29; else if 6080 <= SICCD <= 6082 then FF30 = 29; else if 6090 <= SICCD <= 6099 then FF30 = 29; else if 6100 <= SICCD <= 6100 then FF30 = 29; else if 6110 <= SICCD <= 6111 then FF30 = 29; else if 6112 <= SICCD <= 6113 then FF30 = 29; else if 6120 <= SICCD <= 6129 then FF30 = 29; else if 6130 <= SICCD <= 6139 then FF30 = 29; else if 6140 <= SICCD <= 6149 then FF30 = 29; else if 6150 <= SICCD <= 6159 then FF30 = 29; else if 6160 <= SICCD <= 6169 then FF30 = 29; else if 6170 <= SICCD <= 6179 then FF30 = 29; else if 6190 <= SICCD <= 6199 then FF30 = 29; else if 6200 <= SICCD <= 6299 then FF30 = 29; else if 6300 <= SICCD <= 6300 then FF30 = 29; else if 6310 <= SICCD <= 6319 then FF30 = 29; else if 6320 <= SICCD <= 6329 then FF30 = 29; else if 6330 <= SICCD <= 6331 then FF30 = 29; else if 6350 <= SICCD <= 6351 then FF30 = 29; else if 6360 <= SICCD <= 6361 then FF30 = 29; else if 6370 <= SICCD <= 6379 then FF30 = 29; else if 6390 <= SICCD <= 6399 then FF30 = 29; else if 6400 <= SICCD <= 6411 then FF30 = 29; else if 6500 <= SICCD <= 6500 then FF30 = 29; else if 6510 <= SICCD <= 6510 then FF30 = 29; else if 6512 <= SICCD <= 6512 then FF30 = 29; else if 6513 <= SICCD <= 6513 then FF30 = 29; else if 6514 <= SICCD <= 6514 then FF30 = 29; else if 6515 <= SICCD <= 6515 then FF30 = 29; else if 6517 <= SICCD <= 6519 then FF30 = 29; else if 6520 <= SICCD <= 6529 then FF30 = 29; else if 6530 <= SICCD <= 6531 then FF30 = 29; else if 6532 <= SICCD <= 6532 then FF30 = 29; else if 6540 <= SICCD <= 6541 then FF30 = 29; else if 6550 <= SICCD <= 6553 then FF30 = 29; else if 6590 <= SICCD <= 6599 then FF30 = 29; else if 6610 <= SICCD <= 6611 then FF30 = 29; else if 6700 <= SICCD <= 6700 then FF30 = 29; else if 6710 <= SICCD <= 6719 then FF30 = 29; else if 6720 <= SICCD <= 6722 then FF30 = 29; else if 6723 <= SICCD <= 6723 then FF30 = 29; else if 6724 <= SICCD <= 6724 then FF30 = 29; else if 6725 <= SICCD <= 6725 then FF30 = 29; else if 6726 <= SICCD <= 6726 then FF30 = 29; else if 6730 <= SICCD <= 6733 then FF30 = 29; else if 6740 <= SICCD <= 6779 then FF30 = 29; else if 6790 <= SICCD <= 6791 then FF30 = 29; else if 6792 <= SICCD <= 6792 then FF30 = 29; else if 6793 <= SICCD <= 6793 then FF30 = 29; else if 6794 <= SICCD <= 6794 then FF30 = 29; else if 6795 <= SICCD <= 6795 then FF30 = 29; else if 6798 <= SICCD <= 6798 then FF30 = 29; else if 6799 <= SICCD <= 6799 then FF30 = 29; else if 4950 <= SICCD <= 4959 then FF30 = 30; else if 4960 <= SICCD <= 4961 then FF30 = 30; else if 4970 <= SICCD <= 4971 then FF30 = 30; else if 4990 <= SICCD <= 4991 then FF30 = 30; else FF30 = .; run; *assign index to each year-month; proc sort data=msf.msf_ind nodupkey out=zz; by date; data zz; set zz; by date; n+1; keep date n; proc sort data=msf.msf_ind; by date; data msf.msf_ind; merge msf.msf_ind zz; by date; proc sort data=msf.msf_ind; by permno date; run; *************************************************; * Compute estimates for expected skewness. *; *************************************************; %let ind = FF30; *subject to change; data ret; set msf.msf_ind; if shrcd in (10,11); if exchcd in (1,2,3); ln_ret = log(1+ret); * if prc > 5; *subject to change; keep permno date ln_ret &ind n; run; proc sort data=msf.msf_ind nodupkey out=list_date; by date; data list_date; set list_date; keep date; data list_date; set list_date; by date; n+1; run; proc datasets; delete zzz; run; quit; option nonotes; %macro fill; %do i = 3 %to 996; /*3 - 996*/ data z; set ret; if &i-2 <= n <= &i; proc sort data=z; by &ind; proc means data=z noprint; var ln_ret; by &ind; output out=zz p1=p_1 p5=p_5 p50=p_50 p95=p_95 p99=p_99 skew=skew std=std n=observations; data zz; set zz; skew1 = ((p_99-p_50)-(p_50-p_1))/(p_99-p_1); skew5 = ((p_95-p_50)-(p_50-p_5))/(p_95-p_5); n = &i+1; *that is, the skewness estimate for Dec2008 is computed using data from Sep2008-Nov2008; if &ind ne .; rename std = std_alt; label std = 'Std (3months)'; rename skew = skew_alt; label skew = 'Skewness (3months)'; rename skew1 = skew1_alt; label skew1 = 'Skewness1 (3months)'; rename skew5 = skew5_alt; label skew5 = 'Skewness5 (3months)'; rename observations = observations_alt; label observations = 'Number of Stocks used for Skewness Measures (3months)'; keep &ind n std skew skew1 skew5 observations; data zz; merge zz (in=m1) list_date; by n; if m1; proc append data=zz base=zzz; run; %end; %mend fill; %fill; option notes; data ipo.exp_skew_&ind; set zzz; year = year(date); month = month(date); drop n; run; ****************; * MAIN RESULT ; ****************; libname ipo 'C:\Research\IPO'; *this folder contains two SAS datasets (the dataset generated above + IPO data - available upon request); data z; set ipo.z_7508; keep permno date_ipo year month FF30 name deal_number underpricing; *date_ipo - date of the IPO, year - year of the IPO, month - month of the IPO, FF30 - FF30 industry of the IPO, name - name of the company; *deal_number - SDC deal number, underpricing - percentage return from offer price to first-day closing market price; run; proc sort data=z; by FF30 year month; proc sort data=ipo.exp_skew_FF30; by FF30 year month; data z; merge z (in=m1) ipo.exp_skew_FF30; by FF30 year month; if m1; run; *first-day returns and expected skewness (no forward looking information when forming portfolios); proc sort data=z; by year month; proc sort data=z nodupkey out=aaa; by year month; data aaa; set aaa; by year month; a+1; keep year month a; data aaa; merge aaa z; by year month; run; proc datasets; delete zz; run; quit; option nonotes; %macro fill; %do i = 1 %to 379; data aa; set aaa; if a <= &i; * <= or = ; proc rank data=aa out=a group=3; var skew1_alt; ranks skew1_altr; data a; set a; if a = &i; run; proc append data=a base=zz; run; %end; %mend fill; %fill; option notes; proc datasets; delete a aa aaa; run; quit; *this will give you the main results presented in Table 3; proc sort data=zz; by skew1_altr; proc means data=zz n mean t; var underpricing; by skew1_altr; run;