* K.sas -- K.Cheung & D.Brockman 20040310 macro report stats; * For term project X405, UC Berkeley Extension, Spring 2004. *****; * K *; *****; * K calculates and reports correlations, covariance * matrix, skew and kurtosis for a data set for which * the observations are the natural logs of daily returns. * * Invocation: * &K(data_set); * *****; * K *; *****; * Where data_set is the name of a dataset containing * at least 3 variables * * date -- date in format yymmdd. * * dow -- day of week corresponding to date, * represented by a number where * 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri * Observations will be ignored if * dow isn't one of these values. * * other variables -- each variable represents the * natural log of daily return for the * date of the observation. If the price * on the current day is p1, and the price * on the previous day is p0, then the * value of the variable is ln(p1/p0). * * K expects these other variables: * lgbp, lgcd, lgdm, lgjy, lgsf, * representing british pounds, * canadian dollars, deutsche marks, * japanese yen and swiss francs * respectively. * * Caveat: K performs minimal data checking. GIGO. *; %macro K(data_set); * we expect date and dow, because that's the kind of * data we wrote this macro for. But we haven't any use * for them beyond a cursory data check. *; data ktemp (drop = date dow); set &data_set; if (dow in (1,2,3,4,5)); run; *************************** Begin Parts G & I *************************; * produce report; proc corr data=ktemp cov nosimple; title3 Covariance and Correlation (Parts G, I); run; *************************** End Parts G & I ***************************; *************************** Begin Part J *************************; proc means data=ktemp noprint; title3 'Kurtosis and Skew (Part J)'; var lgbp lgcd lgdm lgjy lgsf; output out=Ltemp kurt=kurt_bp kurt_cd kurt_dm kurt_jy kurt_sf skew=skew_bp skew_cd skew_dm skew_jy skew_sf ; run; data _NULL_ ; * output only; set Ltemp; FILE PRINT; put ' '; put ' '; put ' '; put ' Currency' ' Kurtosis' ' Skew'; put ' '; put ' British Pound' (kurt_bp skew_bp) (10.6); put ' Canadian Dollar' (kurt_cd skew_cd) (10.6); put ' Deutsche Mark' (kurt_dm skew_dm) (10.6); put ' Japanese Yen' (kurt_jy skew_jy) (10.6); put ' Swiss Franc' (kurt_sf skew_sf) (10.6); put ' '; run; /* proc print data=Ltemp (drop= _TYPE_ _FREQ_) noobs; title3 Kurtosis and Skew; run; */ *************************** End Part J ***************************; %mend K;