BookmarkSubscribeRSS Feed
psh1025
Calcite | Level 5

I tried to draw Kaplan-Meier curve using proc lifetest and ODS graphics.

Using % let InsetOpts and StmtsBottom in the Macro, I want to display inset table including No. and events. 

I have 4 groups but only first 3 groups are displayed on Survival Curve.

How can I display 4 groups of No. and events?

 

data _null_;

   %let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/141;

   infile "http:&url/templft.html" device=url;

   file 'macros.tmp';

   retain pre 0;

   input;

   if index(_infile_, '</pre>') then pre = 0;

   if pre then put _infile_;

   if index(_infile_, '<pre>') then pre = 1;

run;

%inc 'macros.tmp' / nosource;

 

%ProvideSurvivalMacros

%let InsetOpts = autoalign=(BottomLeft)

               border=true BackgroundColor=GraphWalls:Color Opaque=true;

%macro StmtsBottom;

dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;

layout gridded / columns=3 border=true autoalign=(BottomRight);

entry ""; entry "No."; entry "Events";

%do i = 1 %to 3;

%let t = / textattrs=GraphData&i;

entry halign=right Strval&i &t; entry NObs&i &t; entry NEvent&i &t;

%end;

endlayout;

%mend;  

%CompileSurvivalTemplates

proc format;

value CATEGORY

1 = "A"

2 = "B"

3 = "C"

4 = "D";

RUN;

 

ODS Graphics ON;

PROC LIFETEST data= File_Name

  plots=survival (atrisk test) notable;

TIME FU_time * events (0);

STRATA category;

format category category.;

RUN;

ODS Graphics OFF;

2 REPLIES 2
mkeintz
PROC Star

Are you saying you only get 3 survival curves?  If so, then I doubt there actually is 4 categories found in your data.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
psh1025
Calcite | Level 5
Oh, I am sorry for not being clear.
I mean 4 survival curves are drawn but in an inset table, No. of cases and
events of only first 3 variables are displayed.
No. of cases and events of the last 'D' variable is not shown in an inset
table.
How can I display No. of cases and events of all 4 variables in an inset
table?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 986 views
  • 0 likes
  • 2 in conversation