BookmarkSubscribeRSS Feed
Charles_Liu
Calcite | Level 5

The sas code is in the program.jpg and the Expect results in the result.jpg, Many thanks in advance~

3 REPLIES 3
GraphGuy
Meteorite | Level 14

I'm not 100% sure, but I don't think unicode characacters are supported in the legend, directly, the way your code is trying (it would be nice/convenient if it worked that way, but I've tried it a few different ways and can't get it to work).

 

But I did get it to work a slightly different way ... rather than using a single series statement, with the group= creating 2 lines, you can create a separate variable for each line, and and then specify the unicode character in the 'legendlabel=' for each line.

 

I've mocked-up some data similar to yours to demonstrate...

 

data final;
input dosegp_ aval p1;
datalines;
16 0 0
16 1 0
16 1.8 0
16 1.8 5
16 1.8 10
16 1.8 27
16 1.9 69
16 3.9 69
16 4 90
16 22 90
20 0 0
20 .5 0
20 .5 11
20 1.8 11
20 1.8 44
20 2.2 44
20 2.2 62
20 19 62
20 19 100
20 22 100
;
run;

 

/* Rather than doing it this way...
proc sgplot data=final;
series x=aval y=p1 / group=dosegp_;
run;
*/

 

/* create 2 separate variables to plot */
data final_mod; set final;
if dosegp_=16 then p1_16=p1;
if dosegp_=20 then p1_20=p1;
run;


title "Kaplan-Meier";
footnote "Log-rank P value";

 

ods escapechar='^';proc sgplot data=final_mod;
series x=aval y=p1_16 / lineattrs=(color=red thickness=1.5 pattern=shortdash)
   name='line16' legendlabel="16 mg/m^{unicode '00b2'x}";
series x=aval y=p1_20 / lineattrs=(color=blue thickness=1.5)
   name='line20' legendlabel="20 mg/m^{unicode '00b2'x}";
scatter x=aval y=p1 / markerattrs=(symbol=plus size=7 color=black)
   name='rp' legendlabel="Censor";
keylegend 'line16' 'line20' 'rp' / location=outside down=1 position=bottom;
yaxis label="Response Probability (%)" values=(0 to 100 by 10);
xaxis label="Time (Months)" values=(0 to 22 by 2);
run;

 

plot_squared.png

Charles_Liu
Calcite | Level 5

Yes,thanks, I dealt with it in the same way that you did and it worked.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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