This section illustrates the discussion in the section Graph Templates in the context of changing the default title and Y-axis label for a Q-Q plot created with PROC ROBUSTREG. The data set Stack is created by the following statements:
data stack; input x1 x2 x3 y @@; datalines; 80 27 89 42 80 27 88 37 75 25 90 37 62 24 87 28 62 22 87 18 62 23 87 18 62 24 93 19 62 24 93 20 58 23 87 15 58 18 80 14 58 18 89 14 58 17 88 13 58 18 82 11 58 19 93 12 50 18 89 8 50 18 86 7 50 19 72 8 50 19 79 8 50 20 80 9 56 20 82 15 70 20 91 15 ;
The following statements request a Q-Q plot for robust residuals created by PROC ROBUSTREG:
ods trace on; ods graphics on; proc robustreg data=stack plots=qqplot; ods select QQPlot; model y = x1 x2 x3; run; ods trace off;
The Q-Q plot is shown in Output 22.1.1.
Output 22.1.1: Default Q-Q Plot from PROC ROBUSTREG

The ODS TRACE ON statement requests a record of all the ODS output objects created by PROC ROBUSTREG. The trace output is as follows:
Output Added: ------------- Name: QQPlot Label: Residual Q-Q Plot Template: Stat.Robustreg.Graphics.QQPlot Path: Robustreg.DiagnosticPlots.QQPlot -------------
ODS Graphics creates the Q-Q plot from an ODS data object named QQPlot and a graph template named Stat.Robustreg.Graphics.QQPlot, which is the default template provided by SAS. Default templates that SAS supplies are saved in the Sashelp.Tmplmst template store (see the section Graph Templates).
To display the default template definition, open the Templates window by typing odstemplates (or odst for short) in the command line. Expand Sashelp.Tmplstat and click the folder.
Next, open the folder and then open the folder. Then right-click the QQPlot template icon and select . This opens the Template Browser. You can copy this template to an editor to edit it.
Alternatively, you can submit the following statements to display the QQPlot template definition in the SAS log:
proc template; source Stat.Robustreg.Graphics.QQPlot; run;
The SOURCE statement specifies the template name. You can copy and paste the template source into the Program Editor and modify it. The template, with a PROC TEMPLATE and RUN statement added, is shown next:
proc template;
define statgraph Stat.Robustreg.Graphics.QQPlot;
notes "Q-Q Plot for Standardized Robust Residuals";
dynamic _DEPLABEL Residual _byline_ _bytitle_ _byfootnote_;
BeginGraph;
ENTRYTITLE "Q-Q Plot of Residuals for " _DEPLABEL;
Layout Overlay / yaxisopts=(label="Standardized Robust Residual")
xaxisopts=(label="Quantile");
SCATTERPLOT y=eval (SORT(DROPMISSING(RESIDUAL))) x=eval (
PROBIT((NUMERATE(SORT(DROPMISSING(RESIDUAL))) -0.375)/(0.25 +
N(RESIDUAL)))) / primary=true
markerattrs=GRAPHDATADEFAULT
rolename=(q=eval(
PROBIT((NUMERATE(SORT(DROPMISSING(RESIDUAL))) -0.375)/(0.25 +
N(RESIDUAL)))) s=eval (SORT(DROPMISSING(RESIDUAL))))
tip=(q s) tiplabel=(q= "Quantile" s="Residual");
lineparm slope=eval (STDDEV(RESIDUAL)) Y=eval (MEAN(RESIDUAL)) X=0 /
clip=false lineattrs=GRAPHREFERENCE extend=true;
EndLayout;
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
EndGraph;
end;
run;
In the template, the default title of the Q-Q plot is specified by the ENTRYTITLE statement. The variable _DepLabel is a dynamic variable that provides the name of the dependent variable in the regression analysis. In this case, the name
is y. In this template, the label for the axes are specified by the LABEL= suboption of the YAXISOPTS= option for the LAYOUT OVERLAY
statement. In other templates, the axis labels come from the column labels of the X-axis and Y-axis columns of the data object.
You can see these labels by specifying ODS OUTPUT with the plot data object and running PROC CONTENTS with the resulting SAS
data set.
Suppose you want to change the title to "Analysis of Residuals", and you want the Y-axis label to display the name of the dependent variable. First, replace the ENTRYTITLE statement with the following statement:
entrytitle "Analysis of Residuals";
Next, replace the LABEL= suboption with the following:
label=("Standardized Robust Residual for " _DEPLABEL)
You can use dynamic text variables such as _DepLabel in any text element.
You can then submit the modified template definition as you would any SAS program, for example, by selecting from the menu. After submitting the PROC TEMPLATE statements, you should see the following message in the SAS log:
NOTE: STATGRAPH 'Stat.Robustreg.Graphics.QQPlot' has been
saved to: SASUSER.TEMPLAT
For more information about graph templates and the graph template language, see the section Graph Templates.
Finally, resubmit the PROC ROBUSTREG statements to display the Q-Q plot created with your modified template. The following statements create Output 22.1.2:
proc template;
define statgraph Stat.Robustreg.Graphics.QQPlot;
notes "Q-Q Plot for Standardized Robust Residuals";
dynamic _DEPLABEL Residual _byline_ _bytitle_ _byfootnote_;
BeginGraph;
entrytitle "Analysis of Residuals";
Layout Overlay /
yaxisopts=(label=("Standardized Robust Residual for " _DEPLABEL))
xaxisopts=(label="Quantile");
SCATTERPLOT y=eval (SORT(DROPMISSING(RESIDUAL))) x=eval (
PROBIT((NUMERATE(SORT(DROPMISSING(RESIDUAL))) -0.375)/(0.25 +
N(RESIDUAL)))) / primary=true
markerattrs=GRAPHDATADEFAULT
rolename=(q=eval(
PROBIT((NUMERATE(SORT(DROPMISSING(RESIDUAL))) -0.375)/(0.25 +
N(RESIDUAL)))) s=eval (SORT(DROPMISSING(RESIDUAL))))
tip=(q s) tiplabel=(q= "Quantile" s="Residual");
lineparm slope=eval (STDDEV(RESIDUAL)) Y=eval (MEAN(RESIDUAL)) X=0 /
clip=false lineattrs=GRAPHREFERENCE extend=true;
EndLayout;
if (_BYTITLE_)
entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else
if (_BYFOOTNOTE_)
entryfootnote halign=left _BYLINE_;
endif;
endif;
EndGraph;
end;
run;
proc robustreg data=stack plots=qqplot;
ods select QQPlot;
model y = x1 x2 x3;
run;
Output 22.1.2: Q-Q Plot with Modified Title and Y-Axis Label

If you have not changed the default template search path, the modified template QQPlot is used automatically because Sasuser.Templat occurs before Sashelp.Tmplmst in the ODS search path. For more information about the template search path and the ODS PATH statement, see the sections
Saving Customized Templates, Using Customized Templates, and Reverting to the Default Templates.
You do not need to rerun the PROC ROBUSTREG analysis after you modify a graph template if you have stored the plot in an ODS document. After you modify your template, you can submit the PROC DOCUMENT statements in Example 21.4 in ChapterĀ 21: Statistical Graphics Using ODS, to replay the Q-Q plot with the modified template. You can run the following statements to revert to the default template:
proc template; delete Stat.Robustreg.Graphics.QQPlot / store=sasuser.templat; run;