I am trying to plot a nelson-aalen (cumulative incidence) curve with the y-axis (incidence) on a logarithmic scale. I have been using proc gplot to create the NA curve, but cannot find the option of changing the y-axis to a log scale. I am happy to use a solution that doesn't rely on proc gplot
Any suggestions?
Hi @ghbg,
For PROC GPLOT (i.e. SAS/GRAPH) you define the axis with an AXIS statement and refer to it in an option of the PLOT statement.
Example:
data have;
do x=1 to 10;
y=exp(x);
output;
end;
run;
goptions reset=all;
axis1 logbase=e logstyle=power;
proc gplot data=have;
plot y*x / vaxis=axis1;
run;
quit;
Hi @ghbg,
For PROC GPLOT (i.e. SAS/GRAPH) you define the axis with an AXIS statement and refer to it in an option of the PLOT statement.
Example:
data have;
do x=1 to 10;
y=exp(x);
output;
end;
run;
goptions reset=all;
axis1 logbase=e logstyle=power;
proc gplot data=have;
plot y*x / vaxis=axis1;
run;
quit;
thanks for this.
what i actually want to do is have the y-axis log-scaled, meaning that the distance between the ticks represent exponentially more of the axis value as you move along the axis - this would mean, for example, ticks that are the same distance apart on the y-axis represent 1,10,100,1000,10000, and so on.
the final graph will look something like the attached, which i made in stata using the cumhaz ylog options of the stsgraph command.
The code below creates a graph similar to yours:
/* Create test data */
data have;
do t=0 to 3 by 0.05;
a=0.0265*t+0.00583;
b=0.0416*t+0.00295;
output;
end;
run;
/* Create graph from test data */
proc format;
value ytickm
.05, .1=[4.2]
other=' ';
run;
data tick015;
length text $9 function $5;
function='move'; xsys='2'; ysys='2'; x=-0.02; y=0.15; output;
function='label'; position='<'; text='0.15 '; hsys='D'; size=9; output;
run;
goptions reset=all cback=CXEAF2F3;
title 'Nelson-Aalen cumulative hazard estimates';
legend1 label=none frame cborder=black cframe=white value=('group=A' 'group=B');
symbol1 i=stepjr c=blue;
symbol2 i=stepjr c=red;
axis1 order=0 to 3 offset=(1) label=('analysis time') minor=none;
axis2 logbase=10 logstyle=expand order=(.0015625 .003125 .00625 .0125 .025 .05 .1 .2)
offset=(0,0) label=none major=none;
proc gplot data=have annotate=tick015;
format a b ytickm.;
plot a*t=1 b*t=2 / overlay haxis=axis1 vaxis=axis2 legend=legend1
vref=0.05 0.1 0.15 cvref=CXEAF2F3;
run;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.