/*-----------------------------------------------------------------
            S A S   S A M P L E   L I B R A R Y                   
                                                                  
      NAME: TREGEX1                                               
     TITLE: Documentation Example 1 for PROC TRANSREG             
   PRODUCT: STAT                                                  
    SYSTEM: ALL                                                   
      KEYS: regression analysis, transformations                  
     PROCS: TRANSREG                                              
      DATA:                                                       
                                                                  
   SUPPORT: saswfk                UPDATE: July 25, 2010           
       REF: PROC TRANSREG, EXAMPLE 1                              
      MISC:                                                       
-----------------------------------------------------------------*/

ods graphics on;

title 'Gasoline Example';
title2 'Iteratively Estimate NOx, CpRatio, EqRatio, and Fuel';

* Fit the Nonparametric Model;
proc transreg data=sashelp.Gas solve test nomiss plots=all;
   ods exclude where=(_path_ ? 'MV');
   model mspline(NOx / nknots=9) = spline(EqRatio / nknots=9)
                                   monotone(CpRatio) opscore(Fuel);
run;

title2 'Now fit log(NOx) = b0 + b1*EqRatio + b2*EqRatio**2 +';
title3 'b3*CpRatio + Sum b(j)*Fuel(j) + Error';

*-Fit the Parametric Model Suggested by the Nonparametric Analysis-;
proc transreg data=sashelp.Gas solve ss2 short nomiss plots=all;
   model log(NOx) = pspline(EqRatio / deg=2) identity(CpRatio)
                    opscore(Fuel);
run;