SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
tan-wongv
Obsidian | Level 7

I ran the following code and got the curve below.

proc lifetest data=sasuser.combine_aim2n2 plots=survival(f) timelist=(0 to 132 by 12);
time month2*ui2(0);
run;

Screenshot 2024-05-15 021346.png

Would there be a way to change the scale of x axis from 0 25 50 75 100 125 to 0 12 24 36 48 60 72 84 96 108 120 132? 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @tan-wongv,

 


@tan-wongv wrote:

Would there be a way to change the scale of x axis from 0 25 50 75 100 125 to 0 12 24 36 48 60 72 84 96 108 120 132? 


Yes, I see three ways to do this, the simplest of which is a combination of three survival (plot) options:

  • Specify those tick marks in the ATRISK option.
  • Add the ATRISKTICKONLY option.
  • Make the "At Risk" display invisible by using a tiny proportion in the OUTSIDE option.
proc lifetest data=sasuser.combine_aim2n2 plots=survival(f atrisk(outside(1e-6))=0 to 132 by 12 atrisktickonly);
time month2*ui2(0);
run;

It is possible, though, that the last tick mark (132) is not displayed if the greatest failure time is less than 132.

 

The other two ways are more cumbersome:

  • Write the data needed for the plot to a dataset (by using the OUTSURV= option of the PROC LIFETEST statement and a subsequent DATA step) and then use PROC SGPLOT to create the plot where you have the XAXIS statement and its various options available.
  • Modify a copy of the ODS template underlying the plot, which is Stat.Lifetest.Graphics.ProductLimitFailure. Change the first occurrence of
    linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS ...
    in the PROC TEMPLATE code to
    linearopts=(viewmax=132 tickvaluelist=(0 12 24 36 48 60 72 84 96 108 120 132) ...

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @tan-wongv,

 


@tan-wongv wrote:

Would there be a way to change the scale of x axis from 0 25 50 75 100 125 to 0 12 24 36 48 60 72 84 96 108 120 132? 


Yes, I see three ways to do this, the simplest of which is a combination of three survival (plot) options:

  • Specify those tick marks in the ATRISK option.
  • Add the ATRISKTICKONLY option.
  • Make the "At Risk" display invisible by using a tiny proportion in the OUTSIDE option.
proc lifetest data=sasuser.combine_aim2n2 plots=survival(f atrisk(outside(1e-6))=0 to 132 by 12 atrisktickonly);
time month2*ui2(0);
run;

It is possible, though, that the last tick mark (132) is not displayed if the greatest failure time is less than 132.

 

The other two ways are more cumbersome:

  • Write the data needed for the plot to a dataset (by using the OUTSURV= option of the PROC LIFETEST statement and a subsequent DATA step) and then use PROC SGPLOT to create the plot where you have the XAXIS statement and its various options available.
  • Modify a copy of the ODS template underlying the plot, which is Stat.Lifetest.Graphics.ProductLimitFailure. Change the first occurrence of
    linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS ...
    in the PROC TEMPLATE code to
    linearopts=(viewmax=132 tickvaluelist=(0 12 24 36 48 60 72 84 96 108 120 132) ...
tan-wongv
Obsidian | Level 7

Thank you very much for your help!

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 584 views
  • 1 like
  • 2 in conversation