Adding Curves to Graphs

Call a Procedure to Create Data for a Curve

In Chapter 5: Adding Variables to the DataObject, you created a residual plot. In this chapter you also create a scatter plot of the independent and dependent variables that shows the model’s predicted values and the upper and lower 95% limits for individual predictions. The REG procedure outputs the predicted values with the P= option in the MODEL statement, and the upper and lower prediction limits with the LCL= and UCL= options.

Type or copy the following statements into a program window, and select ProgramRun from the main menu.

   declare DataObject dobj; 
   dobj = DataObject.CreateFromFile("Hurricanes"); 
   dobj.WriteVarsToServerDataSet( {"wind_kts" "min_pressure"}, 
      "Work", "Hurr", true ); 
   proc reg data=Hurr plots=none; 
      model wind_kts = min_pressure; 
      output out=RegOut P=Pred R=Residual LCL=LCL UCL=UCL; 
   ok = CopyServerDataToDataObject( "Work", "RegOut", dobj,  
      {"Pred" "Residual" "LCL" "UCL"}, /* names on server */ 
      {"Pred" "Residual" "LCL" "UCL"}, /* names in DataObject */ 
      {"Predicted" "Residuals" "Lower Conf. Limit" "Upper Conf. Limit"},  
      true ); 

The first two sets of statements are explained in Chapter 2: Reading and Writing Data. The next two sets of statements are similar to statements in the example from Chapter 5: Adding Variables to the DataObject.

Whenever you want to add a line or curve to a plot, you need to specify the following:

  • whether the curve will be drawn on top of observations or under them

  • the coordinate system in which the curve will be drawn

  • the color, line style, and line width of the curve

  • the coordinates of the curve

These aspects are discussed in the SAS/IML Studio online Help.