BookmarkSubscribeRSS Feed
WKC
Calcite | Level 5 WKC
Calcite | Level 5

Hi,

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;

               endlayout;

            endlayout;

... ...

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_odsgraph_a00...

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.

Thanks!

4 REPLIES 4
Reeza
Super User

What do you mean by dynamic variables in this context? What are you changing and what do you expect the output to be?

WKC
Calcite | Level 5 WKC
Calcite | Level 5

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...

DanH_sas
SAS Super FREQ

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.

Thanks!
Dan

WKC
Calcite | Level 5 WKC
Calcite | Level 5

Works for me. Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1217 views
  • 3 likes
  • 3 in conversation