proc sgplot data=lsmeans_cog_plot noautolegend;
styleattrs
datacolors=(steelblue darkorange forestgreen crimson)
datacontrastcolors=(steelblue darkorange forestgreen crimson);
band x=year lower=lower upper=upper /
group=group
transparency=0.7
name="band";
series x=year y=estimate /
group=group
markers
markerattrs=(symbol=circlefilled size=9)
lineattrs=(thickness=2.5)
name="line"
legendlabel=" ";
xaxis label="Year"
values=(2008 to 2020 by 2)
labelattrs=(size=12pt)
valueattrs=(size=11pt);
yaxis label="cognitive score"
labelattrs=(size=12pt)
valueattrs=(size=11pt);
keylegend "line" /
title="self-report hearing loss"
titleattrs=(size=11pt)
valueattrs=(size=10pt)
location=inside
position=bottomleft
noborder;
run;
I tried usinginset "A" / position=topleft textattrs=(size=16pt weight=bold) backcolor=white noborder;,
but this places the “A” inside the plotting area. I also triedtitle j=left h=16pt bold "A";,
which positions the “A” outside the graph entirely.
Ideally, I would like the panel label to appear —the “A” positioned just outside the plotting area but within the overall figure boundary (above yaxis label).
/*****************************/
%let label1=A(*ESC*){sup 'mw -1'} ;
data _anno;
length label $ 200;
drawspace="graphpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=5; y1=95;label="&label1."; output;
run;
proc sgplot data=sashelp.class sganno=_anno;
scatter x=weight y=height;
xaxis label=' ';
yaxis label=' ';
run;
I would think the TEXT command in PROC SGPLOT would work, that's what it was designed to do (but I have not tried it).
/*****************************/
%let label1=A(*ESC*){sup 'mw -1'} ;
data _anno;
length label $ 200;
drawspace="graphpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=5; y1=95;label="&label1."; output;
run;
proc sgplot data=sashelp.class sganno=_anno;
scatter x=weight y=height;
xaxis label=' ';
yaxis label=' ';
run;
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.