Reputation: 3557
I am doing a simple linear regression as shown below.
data test;
input name $ x y;
datalines;
A 1 0.45
B 0.9 0.1
C 0.8 0.34
D 0.7 0.58
E 0.6 0.7
F 0.5 0.57
G 0.4 0.55
H 0.3 0.44
;
run;
proc reg data=test;
model y=x;
run;
I was given the following plots. Is it possible to label those dots using the name
variable in the original data set? In other words, I want to put "A", "B", ... near those dots.
Upvotes: 1
Views: 403
Reputation: 63424
So, I'm not sure there's a trivial solution for you.
First off, you can add the ID
statement in order to tell SAS that the name
variable is your "ID" variable.
proc reg data=test;
model y=x;
ID name;
run;
Second, you can tell specific plots to display labels - subject to those plots listening (i.e., the plots only display certain labels by default. Remember, these are programmed to work for large datasets as well as small - so 1000 labels would make the plot unreadable.)
proc reg data=test plots=diagnostics(label);
model y=x;
ID name;
run;
This displays "B" on the diagnostic plot - because "B" is an "influential" observation.
You can use the annotate
option to add specific annotations; that can be very challenging, though there is some information out there. The best source is Art Carpenter's Guide to Innovative SAS Techniques, which is a book available from SAS press.
Finally, you can make many (if not all?) of these plots yourself in PROC SGPLOT
or similar. That will give you a lot more flexibility as far as labels and annotations - at the cost of having to write more code to do it.
Upvotes: 1