- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I would like to change the text size of a specific values in yaxistable in a PROC SGPLOT. To do this, I wanted to use an attribute map with the dattrmap option by modifying the textsize based on an index ("id"). However, the textsize option does not seem to work. Is it not available for an attribute map ? How can I achieve this ?
Here is the reproductible code :
data test;
input study :$30. n HR min max;
datalines;
study1 1 2.33 1.8 3.01
study2 2 1.72 1.33 2.22
study3 3 2.88 2.31 3.59
study4 4 1.9 1.55 2.33
study5 5 1.43 0.9 2.27
study6 6 1.63 1.29 2.06
study7 7 1.96 0.85 4.28
study8 8 1.46 1.13 1.88
study9 9 0.83 0.52 1.32
study10 10 1.56 0.87 2.79
study11 11 2.01 1.62 2.49
;
run;
data test;
set test;
if n in (1, 5, 8) then id=1;
else if n in (4, 10) then id=2;
else id=3;
run;
data attrmap;
length textweight $10;
id='text'; value='1'; textcolor='Black'; textsize=8; textweight='bold'; textstyle='normal'; output;
id='text'; value='2'; textcolor='Black'; textsize=7; textweight='normal'; textstyle='italic'; output;
id='text'; value='3'; textcolor='Red'; textsize=4; textweight='normal'; textstyle='normal'; output;
run;
title;
ods graphics / height=5in width=6in;
proc sgplot data=test dattrmap=attrmap noautolegend;
styleattrs axisextent=data;
highlow y=n low=MIN high=MAX / lineattrs=(color=black);
scatter y=n x=HR / markerattrs=(symbol=squarefilled color=black);
scatter y=n x=HR / markerattrs=(size=0) x2axis;
refline 1 / axis=x;
yaxistable study / nolabel location=inside position=left textgroup=id textgroupid=text;
yaxis reverse display=none colorbands=odd colorbandsattrs=(transparency=1) offsetmin=0.02;
xaxis display=(nolabel) VALUEATTRS=(size=8pt);
x2axis display=(nolabel noline noticks novalues);
run;
Thank you for your help
Guillaume
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The attribute textsize
is available for data set sganno=
but not for data set dattrmap=
.
See
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p1d3djir0t86nxn1l10ig8b2jbnl.htm
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm
So you need to overwrite the axis labels using the SG Annotation Function if you really want a different font size. That's done with something like
data ANNO;
DRAWSPACE='datavalue'; X1=0.25; Y1=3; FUNCTION='text'; TEXTSIZE=9; LABEL='Study 3'; output;
run;
Set the axis labels to colour white.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ok thanks, it works fine.
But do I have to list each item? Isn't it possible to do it with an identifier? The aim is to include the graphic in a macro and change the text size according to an identifier (because the label can change).
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
TEXTSIZE= is not a valid Reserved Variable .
But you could use TEXT instead of YAXISTABLE.
data test; input study :$30. n HR min max; datalines; study1 1 2.33 1.8 3.01 study2 2 1.72 1.33 2.22 study3 3 2.88 2.31 3.59 study4 4 1.9 1.55 2.33 study5 5 1.43 0.9 2.27 study6 6 1.63 1.29 2.06 study7 7 1.96 0.85 4.28 study8 8 1.46 1.13 1.88 study9 9 0.83 0.52 1.32 study10 10 1.56 0.87 2.79 study11 11 2.01 1.62 2.49 ; run; data test; set test; if n in (1, 5, 8) then id=1; else if n in (4, 10) then id=2; else id=3; x=0.1; if id=1 then study1=study; if id=2 then study2=study; if id=3 then study3=study; run; title; ods graphics / height=5in width=6in; proc sgplot data=test noautolegend ; styleattrs axisextent=data; highlow y=n low=MIN high=MAX / lineattrs=(color=black); scatter y=n x=HR / markerattrs=(symbol=squarefilled color=black); scatter y=n x=HR / markerattrs=(size=0) x2axis; refline 1 / axis=x; yaxistable study / nolabel location=inside position=left valueattrs=(size=0 color=white ) pad=(right=80); text x=x y=n text=study1/strip contributeoffsets=none textattrs=(size=18 color=red); text x=x y=n text=study2/strip contributeoffsets=none textattrs=(size=14 color=green weight=bold); text x=x y=n text=study3/strip contributeoffsets=none textattrs=(size=10 color=navy weight=bold); yaxis reverse display=none colorbands=odd colorbandsattrs=(transparency=1) offsetmin=0.02; xaxis display=(nolabel) min=0.5 VALUEATTRS=(size=8pt); x2axis display=(nolabel noline noticks novalues); run;