Resources

Creating Default MLDINFO= Data Sets for Use with the PICKMDL statement

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

                    SAS Sample Library

        Name: x12ex09.sas
 Description: Example program from SAS/ETS User's Guide,
              The X12 Procedure
       Title: Creating Default MLDINFO= Data Sets for Use with the PICKMDL statement
     Product: SAS/ETS Software
        Keys: seasonal adjustment of time series
        PROC: X12
       Notes:

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

   %macro makemodel(name,p,d,q,sp,sd,sq,model);
      data "&name" (keep= _MODELTYPE_ _MODELPART_ _COMPONENT_ 
                          _DSVAR_ _PARMTYPE_ _FACTOR_ _LAG_
                            _LABEL_ );
         length _MODELTYPE_ _MODELPART_ _COMPONENT_ _DSVAR_ 
                _PARMTYPE_ $32;
         length _FACTOR_ _LAG_ 8;
         length _LABEL_ $32;

         _MODELTYPE_="ARIMA";
         _MODELPART_="FORECAST";
         _DSVAR_=".";
     
         _LABEL_="("||"&p"||" "||"&d"||" "||"&q"||")("||
                 "&sp"||" "||"&sd"||" "||"&sq"||")s";
          
         /* nonseasonal AR factors */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="AR";
         _FACTOR_=1;
         do _LAG_=1 to &p;
            output;
            end;
          
         /* seasonal AR factors */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="AR";
         _FACTOR_=2;
         do _LAG_=1 to &sp;
            output;
            end;
          
         /* nonseasonal MA factors */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="MA";
         _FACTOR_=1;
         do _LAG_=1 to &q;
            output;
            end;
          
         /* seasonal MA factors */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="MA";
         _FACTOR_=2;
         do _LAG_=1 to &sq;
            output;
            end;
          
         /* nonseasonal DIF */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="DIF";
         _FACTOR_=1;
         _LAG_=1;
         do i_=1 to &d;
            output;
            end;
          
         /* seasonal DIF */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="DIF";
         _FACTOR_=2;
         _LAG_=1;
         do i_=1 to &sd;
            output;
            end;
          
      run; 
      data sasuser.&name;
        length _MODEL_ $32;
        set "&name";
        _MODEL_ = "&model";
      run;

   %mend makemodel;
%makemodel(x12mdl1,0,1,1,0,1,1,Model1); 
%makemodel(x12mdl2,0,1,2,0,1,1,Model2); 
%makemodel(x12mdl3,2,1,0,0,1,1,Model3); 
%makemodel(x12mdl4,0,2,2,0,1,1,Model4); 
%makemodel(x12mdl5,2,1,2,0,1,1,Model5);

data Models;
   length _NAME_ $32;
   set sasuser.x12mdl1 sasuser.x12mdl2 sasuser.x12mdl3
       sasuser.x12mdl4 sasuser.x12mdl5;
   _NAME_ = 'sales';
 run;
title '5 Commonly Used Models';
proc print data=Models;
run ;
data sales;
   set sashelp.air;
   sales = air;
   date = intnx( 'month', '01sep78'd, _n_-1 );
   format date monyy.;
run;
proc x12 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=first;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;
data Models;
   length _NAME_ $32;
   set sasuser.x12mdl5 sasuser.x12mdl4 sasuser.x12mdl3
       sasuser.x12mdl2 sasuser.x12mdl1 ;
   _NAME_ = 'sales';
 run;
 
 proc x12 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=first;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;
 proc x12 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=best;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;