BookmarkSubscribeRSS Feed
ChrisNZ
Tourmaline | Level 20

data test;
set sashelp.class;
if age in (12,13) then gr=1;
else if age =14 then gr=2;
else gr=3;
run;

proc sort data=test;
by gr;
run;
proc format;
value gr
1="kids Reference"
2="teenagers 9 (4-24)"
3="old 78 (32-189)"
;
proc template;
define style mystyle;
parent=styles.sasweb;
class graphwalls /
frameborder=on;
class graphbackground /
color=white;
end;
run;
ods graphics on / reset=all;
ods html style=mystyle path='.' file='newgraph.html';
ods graphics / reset=all width=6.5in height=4.5in border=off ;
legend1 label=none;
proc sgplot data=test DATTRMAP=attrmap1;
scatter x=weight y=Height /group=gr ;
keylegend / location=outside position=bottom NOBORDER down=4;
label gr='Age, years OR (95% CI)';
format gr gr.;
run;

The least you can do is:

1. Please format the code you post

2. Please run the code you post; This code results in an error.

 

Also:

3.The only way to align text in the manner you want is to use fixed-pitch font, as you have been told.

Do you understand this?

4. If you do, you can see why this aligns the legend as you request:

proc format;
  value gr
  1="kids Reference"
  2="teenagers 9 (4-24)"
  3="old 78     (32-189)"
;
...
proc sgplot data=TEST;
...
keylegend / ...  valueattrs=(family='Courier New') ;
...
run;
 

Here is the image (broken on some browsers it seems):

 
 
 
 

Capture.PNG

 

 

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
  • 15 replies
  • 1455 views
  • 5 likes
  • 4 in conversation