SAS Institute. The Power to Know

FOCUS AREAS

Calling SAS Procedures

PROC IML is usually used in conjunction with other DATA or PROC steps. A typical SAS program might use a DATA step to create a SAS data set and then use one or more PROC steps to analyze the data. One of the PROC steps might be IML. Because PROC steps cannot be nested, it is necessary to exit PROC IML before executing a different PROC. This can be problematic because one must lose the state of PROC IML in order to gain access to functionality provided by other components of SAS.

IML Workshop eliminates this limitation by enabling you to utilize DATA and PROC step functionality without losing the state of your IMLPlus program. IML Workshop enables you to access other components of SAS as subroutines to your IMLPlus program. This is a very powerful capability because it means that you can access any statistical procedure provided by SAS from within an IMLPlus program.

Example

  /* generate data */
  x = t( do( -3, 3, .1 ) );
  x2 = x##2; 
  y = x2 + 3*x - 2 + 3*normal( j( nrow(x), 1, 12345 ) );

  declare ScatterPlot plot;
  plot = ScatterPlot.Create("Linear Regression", x, y);
  
  /* save to a data set */
  create imldata var{ x, x2, y };
  append;
  close imldata;

  /* define options for the REG procedure */
  options = "simple corr";
  
  /* call the REG procedure to compute a linear fit 
     without leaving the IML program */
  submit options; /* pass in value of IML variable */
  proc reg data=imldata &options;
    model y=x x2;
    output out=regfit p=pred;
    run;
  endsubmit;

  /* read the predicted value computed by REG into a vector */
  use regfit;
  read all var {pred} into pred;
  close regfit;

  /* continue the IML program */
  plot.DrawUseDataCoordinates();
  plot.DrawLine(x,pred);

Scatter plot with regression fit


Statistics and Operations Research Home Page | SAS/IML Workshop