BookmarkSubscribeRSS Feed
Dan4
Calcite | Level 5

Hello,

 

I am using the STAR command in GCHART to plot my data, which all works fine.

 

The default is to label the spines on the plot with the variable (call it X) used to create the spine.

 

I would like the chart to show a different label than X (call it Y).  Is that possible in GCHART?

 

For example, I would like the splines to correspond the the variable X which has the values "a" "b" "c" "d", but label the

spline with a very different variable Y which takes on different values.

 

Any help would be appreciated.

 

Thank you in advance.

 

Dan

 

2 REPLIES 2
Reeza
Super User

If it's one to one mapping from X to Y, a format may be one way to do it easily. 

GraphGuy
Meteorite | Level 14

Here's some code to 'flesh out' what Reeza suggested.

 

Basically if you have a numeric variable X that you want to use to control the order of the radar chart spokes, but you have a character variable Y that you want to use to label the spokes (rather than using the X-values), you can create a user-defined format so that the x values will print as the y-text.

 

title;

data foo;
length y $1;
input x y line value;
datalines;
1 A 1 5
2 B 1 7
3 C 1 2
4 D 1 1
5 E 1 4
1 A 2 4
2 B 2 6
3 C 2 3
4 D 2 2
5 E 2 5
;
run;

 

proc sql;
create table temp as
select unique x as start, y as label
from foo;
quit; run;
data control; set temp;
fmtname = 'xfmt';
type = 'N';
end = START;
run;
proc format lib=work cntlin=control;
run;

 

title1 "Radar Chart";
proc gradar data=foo;
chart x / overlay=line freq=value;
run;

proc gradar data=foo;
format x xfmt.;
chart x / overlay=line freq=value;
run;

 

The first graph is the radar chart with the spokes labeled with the numeric X, and in the 2nd chart the spokes are labeled with the Y text (via the user-defined format):

 

radar_first.png

 

radar_second.png

 

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
  • 782 views
  • 1 like
  • 3 in conversation