Hi everyone,
Here is my program:
data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/151;
infile "http:&url/templft.html" device=url;
file 'macros.tmp';
retain pre 0;
input;
_infile_ = tranwrd(_infile_, '&', '&');
_infile_ = tranwrd(_infile_, '<' , '<');
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;
%inc 'macros.tmp' / nosource;
%ProvideSurvivalMacros
%let TitleText0 = " ";
%let TitleText1 = " ";
%let TitleText2 = " ";
%let nTitles = 1;
%let GraphOpts = DesignHeight=500px;
%let yOptions = label="Survival Probability"
labelattrs=(size=10pt weight=bold)
tickvalueattrs=(size=8pt)
linearopts=(viewmin=0 viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0));
%let xOptions = label="Time (Months)"
shortlabel="Test"
offsetmin=.05
labelattrs=(size=10pt weight=bold)
tickvalueattrs=(size=8pt)
linearopts=(viewmax=MAXTIME tickvaluelist=(0 6 12 18 24) tickvaluefitpolicy=XTICKVALFITPOL);
%let InsetOpts = autoalign=(BottomLeft) border=true BackgroundColor=GraphWalls:Color Opaque=true;
%let LegendOpts = ;
%macro StmtsTop;
referenceline y=0.5/lineattrs=(color=lightgray);
%mend;
%SurvivalSummaryTable
%CompileSurvivalTemplates
ods _all_ close;
proc format;
invalue bmtnum
'Yes' = 1
'No' = 2;
value bmtfmt
1 = 'Yes'
2 = 'No';
run;
data pcm_(drop=g);
set pcm(rename=(group=g));
Group = input(g, bmtnum.);
run;
ods graphics on;
ods html gpath="&outpath" image_dpi=300;
ods graphics on / reset=index border=off width=10in height=5in imagename="FigureTest" noborder outputfmt=svg;
proc lifetest data=pcm_ plots=survival(atrisk(maxlen=100)=0 to 24 by 6) method=KM;
time T * Status(0);
strata Group / order=internal;
format group bmtfmt.;
run;
ods html close;
And I found that the label in the summary table is too big.
Does anyone know how to modify its font size? Thank you.
I've tried to modify the font size by adding (size=3pt) in the macro %SurvivalTable, below is the code
%macro SurvivalTable;
%local fmt r i t;
%let fmt = bestd6.;
%let r = halign = right;
columnheaders;
layout overlay / pad=(top=5);
if(NSTRATA=1)
layout gridded / columns=6 border=TRUE;
dynamic PctMedianConfid NObs NEvent Median
LowerMedian UpperMedian;
%SurvTabHeader(0)
entry &r NObs;
entry &r NEvent;
entry &r eval(NObs-NEvent);
entry &r eval(put(Median,&fmt));
entry &r eval(put(LowerMedian,&fmt));
entry &r eval(put(UpperMedian,&fmt));
endlayout;
else
layout gridded / columns=7 border=TRUE;
dynamic PctMedianConfid;
%SurvTabHeader(1)
%do i = 1 %to 10;
%let t = / textattrs=GraphData&i(size=3pt);
dynamic StrVal&i NObs&i NEvent&i Median&i
LowerMedian&i UpperMedian&i;
if (&i <= nstrata)
entry &r StrVal&i &t;
entry &r NObs&i &t;
entry &r NEvent&i &t;
entry &r eval(NObs&i-NEvent&i) &t;
entry &r eval(put(Median&i,&fmt)) &t;
entry &r eval(put(LowerMedian&i,&fmt)) &t;
entry &r eval(put(UpperMedian&i,&fmt)) &t;
endif;
%end;
endlayout;
endif;
endlayout;
endcolumnheaders;
%mend;
And this is the output
it became smaller...,but...the label is still truncated or covered..
Hi @JohnChen_TW,
I can reproduce the issue on my workstation. It seems to be limited to the SVG output format, maybe due to a bug. With the more common formats outputfmt=png or outputfmt=jpg I see no problem, so switching to one of those might be the easiest solution.
If you must produce SVG output, a workaround would be to edit the SVG file (which is just a text file): The labels "Yes" and "No" also occur in the at-risk table and their size is acceptable there. Indeed, the parameter textLength for those occurrences is specified as 21.0 for "Yes" and 16.0 for "No" in the SVG file, whereas the corresponding values for the event table are too large: 48.0 and 46.0 (after your font size reduction: 28.0 and 27.0), respectively, which appears to be the reason for the truncated display. Changing these values manually to 21.0 and 16.0, resp., resolves the issue.
In principle, this modification could be automated by reading the SVG file as a text file in a DATA step, searching for the two strings in question (written as hexadecimal ASCII codes: Yes for "Yes" and No for "No"), determining the appropriate textLength values and writing the file back with the modified values. Obviously, this would be quite awkward and not ideal for production level code.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.