************************************************************************ * PROGRAM FOR THE JULY/AUGUST 1997 REVIEW ARTICLE BY DONALD S. ALLEN * * "DO INVENTORIES MODERATE FLUCTUATIONS IN OUTPUT?" PAGES 39 - 50 * ************************************************************************ * NOTE: COMPUSTAT DATA ARE PROPRIETARY AND THUS ARE NOT AVAILABLE * ************************************************************************; libname perm '~/da'; options nocenter ps=59; ********************************************** ** DELETED FROM ORIGINAL DATASET ** ********************************************** ** if sic2 <= 10 ** ** if inv <=0 ** ** if sales <=0 ** ** if any CNUM ending in Z(42 of them) ** ** if dinv=. ** ** if any CNUM with nonconsecutive quarters ** ** 2,112 of them ** ** if sic2 in(40,41,42,44,45,46,47,48,49, ** ** 60,61,62,63,64,65,67, ** ** 70,72,73,75,76,78,79, ** ** 80,82,83,87, ** ** 99) ** **********************************************; ***************************** *** ALTERED Compustat DATA * *****************************; DATA G1;SET PERM.ALTINV(WHERE=(DATE GE 81.2 AND DATE LE 91.1)); * >>> Buffer Stock <<< ...; ********************************* *** UNAGGREGATED by Company *** *********************************; ********************************* * TABLE 2 COLUMN #3 AND #6 *** * TABLE 1 COLUMN #3 *** *********************************; proc corr noprint noprob nosimple data=g1 outp=corout; var dinv dsales; by sic2 cnum; title1; title2 'Results of Proc Corr by Sic2 Cnum'; title3 ' UNAGGREGATED ONLY '; title4; data g3;set corout(keep=dinv _type_ _name_ cnum sic2); if _type_='CORR' and _name_= 'DSALES' ; proc print ; title1; title2 'SELECTED Correlation output dataset'; title3 ' UNAGGREAGATED ONLY '; title4; proc means mean n data=g3;by sic2; title1; title2 'AVERAGE Correlation Coefficient '; title3 'UNAGGREGATED ONLY...81.2 to 91.1 '; title4; ********************************* *** TABLE 2 COLUMN #4 *** *** AGGREGATED by SIC2 CODE *** *********************************; data a1;set g1; proc sort data=a1 out=a2;by sic2 date; proc means noprint data=a2; var dinv dsales ; by sic2 date; output out=aa2 sum=; data a3;set aa2(drop=_type_); proc print ; title1; title2 ' Aggregate(SUM) by Sic2 and Date '; title3 ' 81.2 to 91.1 ; title4; proc corr nosimple data=a3 outp=acorout; var dinv dsales; by sic2 ; title1; title2 'Proc Corr by Sic2(81.2-91.1)'; TITLE3 ' AGGREGATED ONLY '; title4; ********************** * TABLE 1 COLUMN #4 * **********************; * >>> Production Smoothing UNAGGREGATED Firm Level <<< ; DATA p1;SET PERM.ALTINV(WHERE=(DATE GE 81.2 AND DATE LE 91.1)); proc sort data=p1 out=p2;by sic2 cnum; proc means noprint data=p2; var purch sales ; by sic2 cnum; output out=ap2 var=; PROC PRINT DATA=AP2; title1; title2 'Variance by Sic2 and Cnum '; title3 ' 81.2 to 91.1 ' ; title4; data p3;set ap2(drop=_type_); vpvsrat=purch/sales; proc print ; title1; title2 ' RATIO(vpvsrat) = Var Purch / Var Sales '; title3 ' 81.2 to 91.1' ; title4; ********************** * TABLE 1 COLUMN #6 * **********************; * >>> Production Smoothing AGGREGATED <<< ; DATA P1;SET PERM.ALTINV(WHERE=(DATE GE 81.2 AND DATE LE 91.1)); proc sort data=p1 out=p2;by sic2 ; proc means noprint data=p2; var purch sales dinv; by sic2 ; output out=ap2 var=; PROC PRINT DATA=AP2; title1; title2 ' AGGREGATED Variance Sic2 '; title3 ' 81.2 to 91.1 >>> Servo > da/IS1A.sas' ; title4; data p3;set ap2(drop=_type_); vpvsrat=purch/sales; proc print data=p3; title1; title2 ' AGGREGATED RATIO(vpvsrat) = Var Purch / Var Sales '; title3 ' 81.2 to 91.1 ' ; title4; ********************** * TABLE 1 COLUMN #7 * **********************; ** GIVES VARIANCE FOR EACH VARIABLE AND COVARIANCE BETWEEN THEM ; proc corr nosimple cov data=p2 outp=covout; var sales dinv; by sic2 ; title1; title2 'Proc Corr by Sic2 >>> Covariance'; title3 'AGGREGATED ONLY(81.2-91.1)'; title4; ************************************* * TABLE 1 AND TABLE 2 FOR COLUMN #5 * *************************************; DATA ALL;SET PERM.ALTINV(WHERE=(DATE GE 81.2 AND DATE LE 91.1)); * >>> Production Smoothing UNAGGREGATED Firm Level<<< ; data p1;set all; proc sort data=p1 out=p2;by SIC2 CNUM; proc means noprint data=p2;id sic2 ; var purch sales ; BY SIC2 CNUM; output out=ap2 var=vpurch vsales mean=mpurch msales; data ap2;set ap2(drop=_type_); vpvsrat=vpurch/vsales; proc print data=ap2; title1; title2 ' Variance & Mean by SIC2 and CNUM '; title3 ' Servo > da/IS1B.SAS(81.2 to 91.1)' ; title4; * >>> AGGREGATED(SUM) by Sic2 DATE <<< ; data p3;set all; proc sort data=p3 out=p4;by SIC2 DATE; proc means noprint data=p4; var sales ; * var sales inv dinv; * var sales inv ; *BY SIC2 date; BY SIC2 cnum; output out=ap4 sum=ssales;; *output out=ap4 sum=; proc means noprint data=ap4; var ssales ; *var inv sales ; BY SIC2 ; output out=ap5 mean=xsales n=nsales; *output out=ap5 ; data ap5;set ap5(drop=_type_ _freq_); *data ap5;*set ap5; proc print noobs data=ap5; title1; title2 ' Mean and NOB of SUMMED variables by SIC2 '; title3; data g0;set all; proc sort data=g0 out=g1;by SIC2 CNUM; * >>> Buffer Stock <<< ...; ********************************* *** UNAGGREGATED by Company *** *********************************; *** GET COVARIANCE OF SALES DINV *** ; proc corr cov noprint noprob nosimple data=g1 outp=covout; var sales dinv ; by sic2 cnum; title1; title2 'Results of Proc Corr by Sic2 Cnum'; TITLE3 'COVARIANCE...UNAGGREGATED ONLY(81.2-91.1) '; title4; data cov1;set covout(keep=sales _type_ _name_ cnum sic2); if _type_='COV' and _name_= 'DINV' ; *** GET CORRELATION COEFFIEIENT OF DINV AND DSALES *** ; proc corr noprint noprob nosimple data=g1 outp=corout; var dinv dsales ; by sic2 cnum; title1; title2 'Results of Proc Corr by Sic2 Cnum'; title3 ' UNAGGREGATED ONLY(81.2-91.1) '; title4; proc print DATA=COROUT; title1; title2 'ENTIRE Correlation output dataset'; title3 ' UNAGGREGATED ONLY '; title4; data g3;set corout(keep=dinv _type_ _name_ cnum sic2); if _type_='CORR' and _name_= 'DSALES' ; proc print ; title1; title2 'SELECTED Correlation output dataset'; title3 ' UNAGGREAGATED ONLY '; title4; proc means mean n data=g3;by sic2; title1; title2 'AVERAGE Correlation Coefficient '; title3 ' UNAGGREGATED ONLY '; title4; ***************************** ** WEIGHTING OF VARIABLES ** *****************************; data b1;merge ap2 g3 cov1 ap5;by sic2; wght= (_freq_ / nsales) * (msales/xsales);* firm sales / total sales; wvpvsrat=wght*vpvsrat; wdinv=wght*dinv;* correlation coefficient between dinv and dsales.; wsales=wght*sales;* covariance between sales annd dinv..; proc print data=b1; title1; title2 ' Mean Sales of individual companies and TOTAL for sic2 '; title3; proc means sum data=b1;by sic2; var wght wvpvsrat wdinv wsales; title1; TITLE2 ' WEIGHTED SUM OF WGHT, VPVSRAT ...and...'; TITLE3 ' CORR COEF(dinv dsales) COV(sales div)..'; TITLE4 ' 81.2 to 91.1'; title5; run;