BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TomiKong
Fluorite | Level 6

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;

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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;

View solution in original post

3 REPLIES 3
GraphGuy
Meteorite | Level 14

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;

TomiKong
Fluorite | Level 6

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".

GraphGuy
Meteorite | Level 14

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 848 views
  • 0 likes
  • 2 in conversation