Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
rdemass
Fluorite | Level 6

I am wanting to use proc lifetest and run the trend test. 

proc lifetest data=work;
	time time*censor(0);
	strata type / trend test=logrank;
run;

However, my type variable is character, and by default SAS is ordering the different stratas of the variable for the trend test alphabetically. I want to test a different order. I was able to do this as:

 

data work.bios;
	set work.bios;
	if type="a" then ngroup=3;
	if type="b" then ngroup=2;
	if type="c" then ngroup=1;
	if type="d" then ngroup=4;
run;

and then rerun the proc lifetest stratifying by ngroup. However, I was wondering if there was a way to specify the desired order within the proc lifetest and still use strata type. The reason this would be nice is so the outputted tables and graphs would have the names contained within type. And I would avoid adding more variables to my dataset.

Thank you

2 REPLIES 2
ballardw
Super User

You could create a custom format for your Type that shows text values that are alphabetical in the desired order. Might require some creative spelling.

 

And example modifying one from the Proc Lifetest documentation.

proc format;
value $newgroup
'ALL'='Last group A'
'AML-Low Risk'= 'First group B'
'AML-High Risk'='Group in middle C';
;
run;

proc lifetest data=sashelp.BMT ;
   time T * Status(0);
   strata Group / test=logrank trend;
   format group $newgroup.;
run;

Run this with and without the Format statement in the Proc Lifetest to compare results.

Note that in the format F comes before G comes before L so that is the order displayed.

rdemass
Fluorite | Level 6

This does work in the sense that I am not creating a new variable to represent my types. When I implemented this concept, another method is to simply use 'Group 1:...', "Group2:....", Group 3:...." for the formats and include pertinent type info where the ellipses are. This works to order because SAS will order it then by the number ordering. This way also the printout can be descriptive of the original type variable.

My only dissatisfaction is that this solution still adds unwanted character length to the type names i.e., Instead of simply having 'A', 'B', 'C' in the survival curve graph, we now have 'Group 1: C, 'Group 2: A', 'Group 3: B'.

I am still wondering if there is a way to assign some inherent value to the type variable that will not show up anywhere aside from having SAS recognize the order.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2 replies
  • 1451 views
  • 0 likes
  • 2 in conversation