06-30-2011 05:03 PM
I was tring to follow the code below (from the reference link) to modify my survival plot by adding dynamic variables,
layout overlay / . . .;
. . .
dynamic NObs1 NObs2 NObs3 NEvent1 NEvent2 NEvent3;
layout gridded / columns=3 border=TRUE autoalign=(TopRight);
entry ""; entry "Event"; entry "Total";
entry "1"; entry NEvent1; entry NObs1;
entry "2"; entry NEvent2; entry NObs2;
entry "3"; entry NEvent3; entry Nobs3;
I would like to make general statements so that the dynamic variables (say NObsj, where j=level of stratum) can take different values when I plug in stratifying variables with different levels. Can I use a Do loop to do that? but I was not sure how that might work in PROC TEMPLATE, please advise.
07-01-2011 12:48 PM
The dynamic variables is the terminology used by SAS. It seems to me the they take the value of the result from the procedure and save it as a special variable, one could recall these variables in another procedure (say PROC TEMPLATE) to display the value.
In my example, I am trying to enhanced the default KM plot of the PROC LIFETEST precedure by adding number of event, censoring information and additional statistics. By default, the dynamic variable NObs and NEvent store the Number of Observation and Number of Event from the outcome, and if there are several stratifying levels, one can use NObsj and NEventj (where j is the indication of the jth level/ stratum) to recall the variables (i.e. NObs1, NObs2 ..., NEvent1, NEvent2 ... etc). For my question, I wanted to make the (Graph Template) codes flexible enough so that it can populate the results irrespective of the number of levels the variables have.
P.S. A list of dynamic variables available for PROC LIFETEST can be found at http://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#statug_lifetest_sec...
07-06-2011 02:03 PM
Currently, the GTL code does not support a DO loop structure. If you were building this template via macro, you could use a macro %do loop to construct the entries. However, that technique will not work here because the template must be pre-compiled for use by the LIFETEST procedure. The best you can do is code for the "worst case scenario". If you think that you will have, at most, 7 strata, then you can set up seven entries in the table, using a GTL "if" condition to wrap each set of entries conditional on the setting of the NOBSj dynamic variable. Each entry will look something like this:
if (Nobs4) entry "4"; entry NEvent4; entry Nobs4; endif;
Let me know if you have further questions.