Cross-Spectral Analysis

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: speex02.sas
 Description: Example program from SAS/ETS User's Guide,
              The SPECTRA Procedure
       Title: Cross-Spectral Analysis
     Product: SAS/ETS Software
        Keys: spectral and cross-spectral
              analysis of time series
        PROC: SPECTRA
       Notes:

--------------------------------------------------------------*/

data a;
   xl = 0; xll = 0;
   do i = - 10 to 100;
      x = .4 * xl  + rannor(123);
      y = .5 * xll + rannor(123);
      if i > 0 then output;
      xll = xl; xl = x;
   end;
run;

proc spectra data=a out=b cross coef a k p ph s;
   var x y;
   weights 1 1.5 2 4 8 9 8 4 2 1.5 1;
run;

proc contents data=b position;
run;

proc sgplot data=b;
   series x=freq y=a_01_02 / markers markerattrs=(symbol=circlefilled);
   xaxis values=(0 to 4 by 1);
run;

proc sgplot data=b;
   where period < 25;
   series x=period y=a_01_02 / markers markerattrs=(symbol=circlefilled);
   xaxis values=(0 to 30 by 5);
run;