My data and SAS code are as below.
i can change color and pattern for the step line.However, i can't change the thickness for a dash line.
Is there way to thicken the dashline?
Thanks.
data plot;
missing z;
input
Time Survival Event Censored Stratum $;
;
datalines ;
0 1 0 .z Arm_A
1.971252567 0.944444444 1 .z Arm_A
3.811088296 .z 0 0.944444444 Arm_A
5.9137577 0.885416667 1 .z Arm_A
7.392197125 0.826388889 1 .z Arm_A
10.61190965 0.767361111 1 .z Arm_A
15.27720739 0.708333333 1 .z Arm_A
15.70431211 0.649305556 1 .z Arm_A
17.90554415 0.590277778 1 .z Arm_A
18.95687885 0.53125 1 .z Arm_A
19.8110883 0.472222222 1 .z Arm_A
23.22792608 0.413194444 1 .z Arm_A
23.9835729 0.354166667 1 .z Arm_A
28.32032854 0.295138889 1 .z Arm_A
28.91170431 0.236111111 1 .z Arm_A
32.98562628 0.177083333 1 .z Arm_A
37.48665298 0.118055556 1 .z Arm_A
38.57084189 0.059027778 1 .z Arm_A
45.30595483 0 1 .z Arm_A
0 1 0 .z Arm_B
2.694045175 0.95 1 .z Arm_B
3.712525667 0.9 1 .z Arm_B
5.223819302 0.85 1 .z Arm_B
7.030800821 0.8 1 .z Arm_B
7.983572895 0.75 1 .z Arm_B
8.936344969 0.7 1 .z Arm_B
9.46201232 0.65 1 .z Arm_B
10.67761807 0.6 1 .z Arm_B
12.45174538 0.55 1 .z Arm_B
14.88295688 0.5 1 .z Arm_B
16.26283368 0.45 1 .z Arm_B
18.29979466 .z 0 0.45 Arm_B
18.46406571 .z 0 0.45 Arm_B
21.45379877 0.385714286 1 .z Arm_B
23.35934292 0.321428571 1 .z Arm_B
26.7761807 0.257142857 1 .z Arm_B
29.37166324 .z 0 0.257142857 Arm_B
30.2587269 .z 0 0.257142857 Arm_B
33.67556468 .z 0 0.257142857 Arm_B
33.93839836 0 1 .z Arm_B
;
run;
proc template;
define style styles.defstyle;
parent=styles.statistical;
class systemtitle /
backgroundcolor = transparent
fontfamily = "Arial"
;
class systemfooter /
backgroundcolor = transparent
fontfamily = "Arial"
;
class GraphDataDefault /LineThickness = 2px;
class GraphData1 /
contrastcolor=blue linestyle=2 LineThickness = 4px;
class GraphData2 /
contrastcolor=Red linestyle=1 LineThickness = 2px;
end;
run;
ods _all_ close;
ods rtf file='S1_ST.rtf' style=defstyle;
goptions reset=goptions device=png;
ods graphics on / reset ;
proc sgplot data=plot description="";
step x=time y=survival / group=stratum name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
keylegend 's'/ location=inside position=right;
yaxis min=0 label = 'Rate' LABELPOS=top;
xaxis label = 'Months' LABELPOS=right VALUES=(0 to 66 by 6);
inset 'Whisker: Censored'/ position = TOPRIGHT LABELALIGN=left;
run;
ods graphics off;
ods rtf close;
Hi @TristanTang
There is maybe some limitation with the graphic device you're using.
You may want to follow-up with Technical Support as I can reproduce the behavior with SAS9.4 TS1M5.
In the meantime, one possible workaround could be to add the DATASKIN option to your STEP statement, cf the SGPLOT Procedure documentation.
step x=time y=survival / group=stratum name='s' dataskin=crisp;
Hope that helps.
Cheers,
Damo
Funny thing, you can get a png image with
ods listing gpath="&sasforum\graphs" style=defstyle;
ods graphics on / reset=index imagename="S1_ST";
proc sgplot data=plot description="";
step x=time y=survival / group=stratum name='s';
scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;
keylegend 's'/ location=inside position=right;
yaxis min=0 label = 'Rate' LABELPOS=top;
xaxis label = 'Months' LABELPOS=right VALUES=(0 to 66 by 6);
inset 'Whisker: Censored'/ position = TOPRIGHT LABELALIGN=left;
run;
and import it to a rtf file just fine.
Hi,
Thank you so much for your reply.
my question is, i have two line on the graph. Blue line (linestyle=2 LineThickness = 4px) is set thicker than red one (linestyle=1 LineThickness = 2px).
But in the output, the thickness setting seems only effective on the red line (solid line). i would like to know how can i change the thickness for a dash line.
class GraphData1 /
contrastcolor=blue linestyle=2 LineThickness = 4px;
class GraphData2 /
contrastcolor=Red linestyle=1 LineThickness = 2px;
Hi @TristanTang
There is maybe some limitation with the graphic device you're using.
You may want to follow-up with Technical Support as I can reproduce the behavior with SAS9.4 TS1M5.
In the meantime, one possible workaround could be to add the DATASKIN option to your STEP statement, cf the SGPLOT Procedure documentation.
step x=time y=survival / group=stratum name='s' dataskin=crisp;
Hope that helps.
Cheers,
Damo
Although i still can't adjust the thickness directly output to RTF. The option of dataskin=crisp gives an acceptable solution.
Thank you all.
The default output format for RTF is EMF-Plus. This does not support thick lines with patterns. As suggested by others in this thread, use a high dpi PNG output format by setting the OUTPUTFMT and IMAGE_DPI options.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.