BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ghbg
Fluorite | Level 6

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?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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;

View solution in original post

5 REPLIES 5
Reeza
Super User
In SGPLOT look at the X/YAXIS statement which include log options such as logbase, logstyle, and TYPE which specifies the type of the axis.

In general, SG procedures create better quality graphs.

FreelanceReinh
Jade | Level 19

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;
ghbg
Fluorite | Level 6

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.

 

Reeza
Super User
logbase option specifies the intervals. In the solution provided, it was e, but you can change that to a base of 10 which is what you want.
FreelanceReinh
Jade | Level 19

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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 917 views
  • 2 likes
  • 3 in conversation