## Getting Started Example for PROC STATESPACE

```/*--------------------------------------------------------------

SAS Sample Library

Name: stags.sas
Description: Example program from SAS/ETS User's Guide,
The STATESPACE Procedure
Title: Getting Started Example for PROC STATESPACE
Product: SAS/ETS Software
Keys: multivariate time series, state space model
PROC: STATESPACE
Notes:

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

data in;
x=10;  y=40;
x1=0; y1=0;
a1=0; b1=0;
iseed=123;
do t=-100 to 200;
a=rannor(iseed);
b=rannor(iseed);
dx = 0.5*x1 + 0.3*y1 + a - 0.2*a1 - 0.1*b1;
dy = 0.3*x1 + 0.5*y1 + b;
x = x + dx + .25;
y = y + dy + .25;
if t >= 0 then output;
x1 = dx; y1 = dy;
a1 = a; b1 = b;
end;
keep t x y;
run;

proc sgplot data=in noautolegend;
series x=t y=x / markers
markerattrs=(symbol=circlefilled color=blue)
lineattrs=(color=blue pattern=solid);
series x=t y=y / markers
markerattrs=(symbol=circlefilled color=blue)
lineattrs=(color=blue pattern=solid);
run;

var x(1) y(1);
id t;
run;

proc print data=out;
id t;
where t > 190;
run;

proc sgplot data=out noautolegend;
where t > 150;
series x=t y=for1 / markers
markerattrs=(symbol=circle color=blue)
lineattrs=(pattern=solid color=blue);
series x=t y=for2 / markers
markerattrs=(symbol=circle color=blue)
lineattrs=(pattern=solid color=blue);
series x=t y=x / markers
markerattrs=(symbol=circle color=red)
lineattrs=(pattern=solid color=red);
series x=t y=y / markers
markerattrs=(symbol=circle color=red)
lineattrs=(pattern=solid color=red);
refline 200.5 / axis=x;
run;