- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.