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

 

 

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