BookmarkSubscribeRSS Feed
amm8
Calcite | Level 5
I'm trying to draw href lines on a set of plots. The code I'm using for the plots is:

proc gplot data=rays;
plot y*x = rad /haxis=axis1;
by name;
run;

This makes a plot for each name.

I would like to add href lines for each plot. The location of the href line is unique for each name. The locations are values in the dataset rays. Is there an easy way to do this?

Thanks,

Ashy
2 REPLIES 2
DanH_sas
SAS Super FREQ
Hey Ashy,

If you are running SAS 9.2, you can do this easily with PROC SGPLOT. This procedure supports variables on the REFLINE statement. Here is an example using your variables:

[pre]
proc sgplot data=rays;
refline ref_value_column;
scatter x=x y=y / group=rad;
run;
[/pre]

Let me know if you have any other questions about this.

Thanks!
Dan
deleted_user
Not applicable
Hi Ashy,

You can mention the href option in ur plot statement.

proc gplot data=rays;
plot y*x = rad /haxis=axis1 href='href-value;
by name;
run;

But if you want to save the trouble of writing it for each name, then you can use a macro like following:

%macro macro-name(href,name);

proc gplot data=rays;
plot y*x = rad /haxis=axis1 href=&href;
by &name;
run;

%mend;
%macro-name(href1,name1);
%macro-name(href2,name2);
And so on…

But if you want the values to come out directly from the rays datasheet. Then you can use the symput function.

Hope this helps!

Let me know if you have anymore question on this Message was edited by: neophyte

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 3517 views
  • 0 likes
  • 3 in conversation