data loadtons;
   infile 'c:\weekly\feb02\aardatadanq401pre.prn' lrecl=150
              firstobs=10 obs=49 pad missover;


   input
        year    5-8
        @9      yrqtr YYQ6.
        aarcars 18-24
        @25 tons
        aarcars2
        qtr2
        qtr3
        qtr4
        year 69-72
        forecast 73-80
        heat 82-88
        cool 90-96
       ;
hplusc = heat + cool;
heatsq = heat*heat;
year1000 = year*1000;
yearx = year - 1989;

data load2;
   infile 'c:\weekly\feb02\aardatadanq401pre.prn' lrecl=150
             firstobs=10 obs=49 pad missover;

   input
        year    5-8
        @9      yrqtr YYQ6.
        aarcars 18-24
        @25 tons
        aarcars2
        qtr2
        qtr3
        qtr4
        year 69-72
        forecast 73-80
        heat 82-88
        cool 90-96
       ;
hplusc = heat + cool;
heatsq = heat*heat;

proc print data= loadtons;
        title 'A Print of Loadtons';
   format
        yrqtr yyq4.
        ;

proc forecast
        data=load2
        ar=4
        out=b
        outest=c
        trend=2
                outdata
        out1step
        outlimit
        interval=qtr
        lead=2;

        id yrqtr;
        var
            tons
  ;

proc print data=c;
        title 'The Estimates from Proc Forecast';
        format yrqtr yyq4.;


proc print data=b;
        title 'The Ouput Actual and Forecasted from Proc Forecast';
        format yrqtr yyq4. ;


proc autoreg data= loadtons;
   model  tons=aarcars heat cool  / nlag=4 backstep slstay=0.2;
   output out=d p=pred r=resid;

proc plot data=d;
  plot tons*yrqtr='A' pred*yrqtr='P'  resid*yrqtr='R' / overlay;
     format yrqtr yyq4.;

proc print data=d;
        title 'The Ouput Actual and Forecasted from Autoreg';
        format yrqtr yyq4. ;



proc reg data=loadtons;
   model tons=aarcars yearx heat qtr2 qtr3 qtr4/ dw p r cli;
   var yrqtr;
   format yrqtr yyq4.;
   plot tons*yrqtr='a'
        p.*yrqtr='p'
        u95.*yrqtr = 'u'
        l95.*yrqtr='l'
                        /overlay;
run;


/****

data _null_;
   set b;

        file 'c:\weekly\forecast98q4.txt' lrecl=300;
        put
                        yrqtr   yyq4.
                        _type_  $       11-18
                @21     alabama         5.2
                @31     alaska          5.2
                @41     arizona         5.2
                @51     arkansas        5.2
                @61     colorado        5.2
                @71     illinois        5.2
                @81     indiana         5.2
                @91     kansas          5.2
                @101    eastky          5.2
                @111    westky          5.2
                @121    maryland        5.2
                @131    missouri        5.2
                @141    montana         5.2
                @151    newmex          5.2
                @161    ndakota         5.2
                @171    ohio            5.2
                @181    oklahoma        5.2
                @191    pennanth        5.2
                @201    pennbit         5.2
                @211    tenn            5.2
                @221    texas           5.2
                @231    utah            5.2
                @241    virginia        5.2
                @251    wash            5.2
                @261    northwv         5.2
                @271    southwv         5.2
                @281    wyoming         5.2        ;


****/

run;