The GTL conditional
logic is used only to determine which statements are rendered, not
to control what is in the data object. In the following example, the
data object contains columns for DATE, AMOUNT, and LOG(AMOUNT), but
only one scatter plot is created.
if (LOGFLAG)
scatterplot x=date y=amount;
else
scatterplot x=date y=log(amount);
endif;
Also, it is seldom necessary
to test for the existence of option values set by columns or dynamics.
Consider the following statement:
scatterplot x=date y=amount / group=GROUPVAR;
This SCATTERPLOT statement
is equivalent to the following code because option values that are
set by columns that do not exist or dynamics that are uninitialized
simply “drop out” at run time and do not produce errors
or warnings:
if (exists(GROUPVAR))
scatterplot x=date y=amount / group=GROUPVAR;
else
scatterplot x=date y=amount;
endif;
The GTL code that is
conditional must be complete statements, or complete blocks of statements,
or both. The following IF block produces a compile error because there
are more LAYOUT statements than ENDLAYOUT statements:
/* this IF block produces a compile error */
if (exists(SQUAREPLOT))
layout overlayequated / equatetype=square;
else
layout overlay;
endif;
scatterplot x=XVAR y=YVAR;
endlayout;
This is the correct
conditional construct:
if (exists(SQUAREPLOT))
layout overlayequated / equatetype=square;
scatterplot x=XVAR y=YVAR;
endlayout;
else
layout overlay;
scatterplot x=XVAR y=YVAR;
endlayout;
endif;