11-17-2011 02:45 PM
It seems that when I'm using PROC LIFETEST to create a survival plot with number-at-risk printed on the x-axis, that whenever at least one stratum label is more than 3 characters the number-at-risk labels are printed as 1, 2, etc instead of the full strata format labels, while the strata names are printed as "1: [Label stratum 1]", "2: [Label Stratum 2]", etc. in legends (with the corresponding labels of each stratum instead of the bracketed text). See the attached file for an example (created using non-sensical data).
I've been trying to get around this by modifying the template used to create the plots (Stat.Lifetest.Graphics.ProductLimitSurvival) to force the procedure to always print the full label (some additional tweaking will of course be necessary for long format labels), but I can't seem to get very much further at the moment. From what I can tell, the names to print in the figure are actually created before the template is called, since the parts of the plotting statements which hold the labels in question are never declared in the template. These include STRATUM (seems to hold stratum labels), and CLASSATRISK (seems to hold the number-at-risk labels).
Is there any way to figure out where these undeclared variables come from? If not, is there any simpler way to do what I want?
11-17-2011 06:14 PM
In the blockplot statement unde the if (PLOTATRISK) change the class=CLASSATRISK to class=STRATUM
It still has the number but the name is there as well and remember to change both of them (under first IF and second IF).
If you want just the name then you might want to use sgplot on the output dataset instead, search lexjansen.com for a paper and pharmasug in 2011 by Sanjay from SAS.
11-18-2011 03:24 PM
I see. It was helpful to actually have a look at the data that is passed to the plotting procedure. Like you point out, I see now that this won't allow me to add the original labels using a modified template, since the original labels are not to be found in there.
I suppose it's not possible then to modify or create new input data using statements within a template, not even temporary variables (I guess this is a bit of a newbie-question)?
Oh, well. I guess I'll have to write a macro for manual plotting using SGPLOT then. And I think this was the paper you were referring to.
Thanks for your reply!
11-18-2011 09:04 PM
The original IDs are in the variable STRATUMID but I don't know how to add that into the template. You can try replacing the graphdatavalue/graphdatatext with that in the template and see if it works. Replace the classatrisk with STRatum provides the labels as 1: YOURLABEL and 2: YOUR LABEL. The legend will also have that by default and for now I can't see a way around it. SAS support has an example of how to get the atrisk table at the bottom of the graph (rather than inside) you may want to check that one. It'll be fully customized for that particular procedure but will work.
Or contact tech support .