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