I try to create template for
PROC SGRENDER DATA=INDS TEMPLATE=myTemplate;
I want to rotate legend (by Default it Horizontal in any position), but can't find option.
I found ODS LEGEND, but it seems like it's working for PROC GPLOT.
Is there exist such option or another method to rotate legend in SGRENDER?
I want to set text vertically
I did not see an option you could do that either.
The workaround way I could image is using PROC SGPLOT to make a picture for LEGEND and insert this picture into PROC SGRENDER by rotating it 90 degree.
But that would cost you a lot of time and you need to make legend be consistent with original graph.
Here is an example:
%let path=%sysfunc(pathname(work)); *the path stored the picture ;
*Make a picture for Legend;
data x;
input label $ x y s_male_x s_male_y male $ male_x male_y s_female_x s_female_y female $ female_x female_y;
cards;
SEX 0 0 1 0 Male 1.5 0 2.5 0 Female 3.2 0
;
run;
title;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics/width=250px height=40px reset=index imagename='legend' outputfmt=png noborder;
proc sgplot data=x noautolegend pad=0; *noborder;
scatter x=x y=y/markerchar=label markercharattrs=(size=20);
scatter x=s_male_x y=s_male_y/markerattrs=graphdata1(symbol=squarefilled size=20);
scatter x=male_x y=male_y/markerchar=male markercharattrs=(size=20);
scatter x=s_female_x y=s_female_y/markerattrs=graphdata2(symbol=squarefilled size=20);
scatter x=female_x y=female_y/markerchar=female markercharattrs=(size=20);
xaxis display=none;
yaxis display=none;
run;
%sganno
data sganno;
%SGIMAGE(
IMAGE="&path.\legend1.png",
ANCHOR="CENTER" ,
IMAGESCALE="FITHEIGHT",
ROTATE=90,
HEIGHT=10,
HEIGHTUNIT= "PERCENT",
LAYER="FRONT",
DRAWSPACE="WALLPERCENT",
X1=5,
Y1=65,ID="BAR"
)
run;
proc template;
define statgraph y2axis;
begingraph;
layout overlay ;
barchart category=age response=weight/group=sex groupdisplay=cluster ;
annotate / id="BAR";
endlayout;
endgraph;
end;
run;
ods graphics/reset=all;
proc sgrender data=sashelp.class template=y2axis sganno=sganno;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.