Chapter Contents

Previous

Next
SAS Component Language: Reference

Substituting Text in Submit Blocks

In interactive applications, values for statements in a submit block may need to be determined by user input or program input in the application. An SCL feature that supports this requirement is the substitution of text in submit blocks, based on the values of fields or SCL variables.


How Values Are Substituted in Submit Blocks

SCL performs substitution in submit blocks according to the following rules:

CAUTION:
Avoid using the same name for both an SCL variable and a macro variable that you want to use in submitted statements. SCL substitutes the value of the corresponding SCL variable for any name that begins with an ampersand. To guarantee that a name is passed as a macro variable reference in submitted statements, precede the name with two ampersands (for example, &&TABLE).  [cautionend]


Specifying Text for Substitutions

If an SCL variable that is used in a substitution contains a null value, then a blank is substituted for the reference in the submitted statements. This can cause problems if the substitution occurs in a statement that requires a value, so SCL allows you to define a replacement string for the variable. If the variable's value is not blank, the complete replacement string is substituted for the variable reference. To define a replacement string, you can use either the Replace attribute (for a control or field) or the REPLACE statement.

Using the REPLACE Statement

The REPLACE statement acts as an implicit IF-THEN statement that determines when to substitute a specified string in the submit block. Consider the following example:

replace table 'data=&table';
   ...more SCL statements...
submit;
   proc print &table;
   run;
endsubmit;

If the SCL variable TABLE contains ' ' (or _BLANK_), then these statements are submitted:

proc print;
run;

If the SCL variable TABLE contains work.sample, then these statements are submitted:

proc print data=work.sample;
run;

Using the Replace Attribute

In SAS/AF applications, you can also can define replacement strings for a window variable using the Replace attribute in the properties window (for a control) or the attribute window (for a field). The text that you specify for the Replace attribute is substituted for the variable name when the variable name is preceded with an ampersand in submitted statements.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.