Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
SCL variables have most of the same attributes as variables in the base SAS language:
However, SCL variables do not have labels.
SCL provides three categories of variables:
Window Variables |
The name of a window variable is the same as the name
that is assigned to the control or field. The SCL program for the window cannot
change that name.
A window variable also has a data type, which can be
character, numeric, or an object data type. The type is determined by the
value of the Type attribute, which is displayed
in the Properties window (for a control) or in
the Attributes window (for a field). For more information
about data types that are used in SAS/AF applications, see the SAS/AF online
Help and
SAS Guide to Applications Development.
Lengths of window variables are determined as follows:
Nonwindow Variables |
The name of a nonwindow variable is determined by the
first assignment statement that uses the variable, unless the variable is
explicitly defined with a DECLARE or LENGTH statement. Names of nonwindow
variables can be up to 32 characters long.
Nonwindow variables are numeric unless they are explicitly
declared as a different data type.
Lengths of nonwindow variables are determined as follows:
The scope of a variable determines when a value can be assigned to it and when its value is available for use. In general, variables in an SCL program have program scope. That is, their scope is local to the program. They are available for use within the SCL program but not to other parts of SAS software. When the program finishes, the variables no longer exist, so their values are no longer available.
SCL provides a feature for defining variables as local to a DO or SELECT block. To define a variable with this type of scope, use a DECLARE statement inside a DO or SELECT block. Any variable that you declare in this way exists only for the duration of that DO or SELECT block, and its value is available only during that time. For example, the following program uses two variables named SECOND. One variable is numeric by virtue of the first assignment statement. The other is a character variable that is local to the DO block. After the DO block ends, only the numeric SECOND variable is available.
INIT: first=10; second=5; put 'Before the DO block: ' first= second=; do; /* Declare variable THIRD and new */ /* variable SECOND, which is local to */ /* the DO block and is CHAR data type */ declare char(3) second third; second='Jan'; third ='Mar'; /* FIRST is available because */ /* it comes from parent scope. */ put 'Inside the DO block: ' first= second= third=; end; /* THIRD is not available because */ /* it ended when the DO block ended. */ put 'After the DO block: ' first= second= third=; return;
The example produces the following output:
Before the DO block: first=10 second=5 Inside the DO block: first=10 second=Jan third=Mar After the DO block: first=10 second=5 third=.
Although program variables are available only while an SCL program is running, SCL provides features for passing variables to other programs and also for receiving returned values. For more information, see ENTRY and METHOD.
You can also use global macro variables to make variables available outside the SCL program. See Using Macro Variables for details.
System Variables |
Do not declare the _SELF_, _FRAME_, _CFRAME_, _METHOD_, or _EVENT_ system variables inside a CLASS or USECLASS block. SCL automatically sets these values when it is running methods that are defined in CLASS or USECLASS blocks. Redefining any of these system variables can introduce unexpected behavior.
With the exceptions of _EVENT_, _METHOD_, and _VALUE_, you can simply reference a system variable in an SCL program without explicitly declaring it.
Type: Character
Type: Object
Type: Numeric
Type: Numeric
Type: Numeric
" |
modification or selection |
C | command |
D | double click |
P | pop-up menu request |
S | selection or single click. |
_EVENT_ must be explicitly declared in an SCL program. For example:
declare char(1) _event_;
Type: Character.
Type: Object
_METHOD_ must be explicitly declared in an SCL program. In the declaration statement, specify the maximum length for the name of a method. For example:
declare char(40) _method_;
Type: Character.
Type: Character
Type: Object
Type: Character
When _VALUE_ contains the value of a character control, it must be explicitly declared in an SCL program. In the declaration statement, specify the maximum length for a character window control. For example:
declare char(80) _value_;
Type: Character or Numeric.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.