Labeling Individual Points - SAS Programming

In this example, you use the point-labeling feature added in Release 6.07.Because the placing of labels can become very complicated, we refer you to SAS Technical Report P-222, Changes and Enhancements to Base SAS Software, Release 6.07 for the details and show you a labeled plot request where all the defaults have been chosen.

Suppose you want to see a plot of SBP (systolic blood pressure) versus HR (heart rate), and you would like to have each data point labeled so that you can see which person generated that data point.The following program accomplishes just that:

Example

PROC PLOT DATA=CLIN_2;
TITLE 'Plot of SBP versus HR with'?
TITLE2 'NAME as the Labeling variable';
PLOT SBP*HR $ NAME='o';
RUN;

The values of the variable NAME are used to label the individual data points in this example.To specify a label variable, you follow the plot request by a dollar sign ($) and the name of the label variable.You may also specify a plotting symbol in quotation marks or a variable whose value will be used as a plotting symbol.

Here is the output from the previous code:

Output from Example - Labeling Individual Points

Output from Example - Labeling Individual Points

This is a really powerful feature that allows you to identify individual data points on a scatter plot.Obviously,this has limited application with large data sets because there is not enough room to fit all the labels on the plot.

Problems

    The problems in this chapter all use SAS data set CHAP13 as shown here: X

  1. Write the SAS statements to generate a plot of Y by X.
  2. Write the SAS statements to generate a plot of Y by X with a lowercase letter O ('o') as the plotting symbol ('o'` is RC's favorite plotting symbol).
  3. Write the SAS statements to generate plots of Y by X, and Z by X, both on the same set of axes.
  4. Redo Problem 12-3 using a separate plotting symbol for each of the two plots, e.g., ' Y' for the Y by X plot and 'Z' for the Z by X plot.
  5. Write the SAS code to produce a single plot of Y by X with values of CODE as the plotting symbol.
  6. Write the SAS code to produce a plot of Y versus X with each of the data points labeled by value of NAME.

Data set


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAS Programming Topics