This section adds a legend that explains the different colors of lines in the graph. Adding a legend is usually accomplished by using the DrawLegend module that is distributed with SAS/IML Studio. The module is documented in the SAS/IML Studio online Help. The statements that follow show one choice for displaying a legend. Add these at the bottom of the program window, and select → from the main menu. Figure 8.2 shows how the legend appears.
Labels = {"Least-Squares Fit" "95% Prediction Limits"}; LabelSize = 8; /* 8 point font */ LineColor = BLUE || GRAY; /* form 1x2 matrix */ LineStyle = SOLID; /* all lines are solid */ Symbol = -1; /* no symbols */ BackgroundColor = WHITE; Location = 'ILB'; /* Inside, Left, Bottom */ run DrawLegend( FitPlot, Labels, LabelSize, LineColor, LineStyle, Symbol, BackgroundColor, Location );
Note the use of the SAS/IML concatenation operator ||. This operator takes the two predefined integers BLUE and GRAY and concatenates them into a matrix.
Note: Trying to form the matrix by using the following statement does not work because the SAS/IML language interprets that statement as forming a character matrix with values “BLUE” and “GRAY”:
LineColor = {BLUE GRAY}; /* wrong! */
Similarly, as the next statement illustrates, you must use the concatenation operator when creating a matrix from submatrices. You cannot write
Values = {N[2] NValue2[1]}; /* wrong! */