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

Hello,

I am a layman SAS user. Can anyone please tell me how I change the starting point of a Kaplan graph? For example, I want to start directly from 10 months onward.

Stage.png

Like in this graph I only need 10 months onward to 60. How do I exclude a timeline from 0 to 10?

I am using this statement [proc lifetest data=WORK.CS notable plots=survival (atrisk(maxlen=13)=0 to 60 by 12) MAXTIME=60;
time 'Survival months'n*'Vital status'n(1);
Strata Gender;
run;}

Is there any simple plain statement like MAXIME limiting the ending point?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
/*
Here could get more simple code,
I missed an important option TYPE=STEP
*/
ods select none ;
ods output  SurvivalPlot= SurvivalPlot ;
proc lifetest data=sashelp.bmt  plots=survival(cl atrisk=(0 to 2500 by 500) ) ; 
time T*Status(0);
Strata Group;
run;
ods select all ;



proc sgplot data=SurvivalPlot;
where Time>=500 ;   /* <------- Here is */
band x=Time lower=SDF_LCL  upper=SDF_UCL /group=Stratum transparency=0.8 type=step;
step x=Time y=Survival /group=Stratum name='a';
scatter x=Time y=Censored/group=Stratum markerattrs=(symbol=plus);
xaxistable AtRisk/ x=tAtRisk class=Stratum colorgroup=Stratum location=inside  
                   TITLEATTRS=(size=8 weight=bold) VALUEATTRS=(size=8 weight=bold);
inset '+ Censored' /position=ne border;
keylegend 'a'/title='Disease Group';
yaxis values=(0 to 1 by 0.2);
run;

Ksharp_0-1673005636061.png

 

View solution in original post

4 REPLIES 4
sbxkoenk
SAS Super FREQ

Hello,

 

Not sure whether it's possible in a very easy way (like using a simple option in PROC LIFETEST).

 

If not, you can definitely change the (outlook of the) plot the way you want the "hard" way.

 

Koen

Ksharp
Super User
/*
I think there is NOT any simple plain statement to get this
*/
ods select none ;
ods output  SurvivalPlot= SurvivalPlot ;
proc lifetest data=sashelp.bmt  plots=survival(cl atrisk=(0 to 2500 by 500) ) ; 
time T*Status(0);
Strata Group;
run;
ods select all ;

data SurvivalPlot1;
 merge SurvivalPlot SurvivalPlot(keep=StratumNum Time 
 rename=(StratumNum=_StratumNum Time=_Time) firstobs=2);
output;
if StratumNum=_StratumNum  then do;
 do Time=Time+1 to _Time-1;
  call missing(Censored,AtRisk,tAtRisk);output;
 end;
end;
drop _StratumNum _Time;
run;
data SurvivalPlot2;
 set SurvivalPlot1;
 by StratumNum;
 retain new_SDF_UCL new_SDF_LCL new_Survival;
 if first.StratumNum then call missing(new_SDF_UCL,new_SDF_LCL,new_Survival);
 if not missing(SDF_UCL) then  new_SDF_UCL=SDF_UCL;
 if not missing(SDF_LCL) then  new_SDF_LCL=SDF_LCL;
 if not missing(Survival) then  new_Survival=Survival;
 Stratum=scan(Stratum,-1,':');
run;
proc sgplot data=SurvivalPlot2;
where Time>=500 ;   /* <------- Here is */
band x=Time lower=new_SDF_LCL  upper=new_SDF_UCL /group=Stratum transparency=0.8 ;
step x=Time y=new_Survival /group=Stratum name='a';
scatter x=Time y=Censored/group=Stratum markerattrs=(symbol=plus);
xaxistable AtRisk/ x=tAtRisk class=Stratum colorgroup=Stratum location=inside  
                   TITLEATTRS=(size=8 weight=bold) VALUEATTRS=(size=8 weight=bold);
inset '+ Censored' /position=ne border;
keylegend 'a'/title='Disease Group';
yaxis values=(0 to 1 by 0.2);
run;

Ksharp_0-1672745948848.png

 

 

If you remove "where Time>=500 ; " ,you could get this :

Ksharp_1-1672745981489.png

 

Ksharp
Super User
/*
Here could get more simple code,
I missed an important option TYPE=STEP
*/
ods select none ;
ods output  SurvivalPlot= SurvivalPlot ;
proc lifetest data=sashelp.bmt  plots=survival(cl atrisk=(0 to 2500 by 500) ) ; 
time T*Status(0);
Strata Group;
run;
ods select all ;



proc sgplot data=SurvivalPlot;
where Time>=500 ;   /* <------- Here is */
band x=Time lower=SDF_LCL  upper=SDF_UCL /group=Stratum transparency=0.8 type=step;
step x=Time y=Survival /group=Stratum name='a';
scatter x=Time y=Censored/group=Stratum markerattrs=(symbol=plus);
xaxistable AtRisk/ x=tAtRisk class=Stratum colorgroup=Stratum location=inside  
                   TITLEATTRS=(size=8 weight=bold) VALUEATTRS=(size=8 weight=bold);
inset '+ Censored' /position=ne border;
keylegend 'a'/title='Disease Group';
yaxis values=(0 to 1 by 0.2);
run;

Ksharp_0-1673005636061.png

 

Medidata
Fluorite | Level 6
Thank you, It's worked....

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 602 views
  • 5 likes
  • 3 in conversation