If I generate the codes below, how to mark the point (5, 25) on the figure with a label "this is one point"? Thanks
data mydata;
do i=-10 to 10;
x=i;
y=i**2;
output;
end;
drop i;
run;
goptions reset=global;
symbol v=dot i=spline c=blue;
axis1 order=-10 to 10 by 5;
axis2 order=0 to 150 by 50;
proc gplot data=mydata;
plot y*x/haxis=axis1 vaxis=axis2;
run; quit;
It's all data-driven...
data mydata;
do i=-10 to 10;
x=i;
y=i**2;
output;
end;
drop i;
run;
data mydata; set mydata;
if x=5 and y=25 then mytext="this is the 1st point";
if x=8 and y=64 then mytext="this is the 2nd point";
run;
goptions reset=global;
symbol v=dot i=spline c=blue pointlabel=("#mytext");
axis1 order=-10 to 10 by 5;
axis2 order=0 to 150 by 50;
proc gplot data=mydata;
plot y*x/haxis=axis1 vaxis=axis2;
run; quit;
If you're using a fairly recent version of SAS, and you're using a traditional SAS/Graph device (not java or activex), the easiest way to do this is with the "pointlabel" feature of the symbol statement...
data mydata;
do i=-10 to 10;
x=i;
y=i**2;
output;
end;
drop i;
run;
data mydata; set mydata;
if x=5 and y=25 then mytext="this is one point";
run;
goptions reset=global;
symbol v=dot i=spline c=blue pointlabel=("#mytext");
axis1 order=-10 to 10 by 5;
axis2 order=0 to 150 by 50;
proc gplot data=mydata;
plot y*x/haxis=axis1 vaxis=axis2;
run; quit;
Thanks.But how to add labels to two specific points? (5,25) is labeled with "this is the lst point" and (8,64) is labeled with "this is the 2nd point".
It's all data-driven...
data mydata;
do i=-10 to 10;
x=i;
y=i**2;
output;
end;
drop i;
run;
data mydata; set mydata;
if x=5 and y=25 then mytext="this is the 1st point";
if x=8 and y=64 then mytext="this is the 2nd point";
run;
goptions reset=global;
symbol v=dot i=spline c=blue pointlabel=("#mytext");
axis1 order=-10 to 10 by 5;
axis2 order=0 to 150 by 50;
proc gplot data=mydata;
plot y*x/haxis=axis1 vaxis=axis2;
run; quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.