|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:
Most SCL programs are associated with a window for interacting with users.
An SCL program for a window has variables that are associated with the controls
and fields in the window. These variables are called window variables, and
they are the means by which users and SCL programs communicate with each
other. You can use these variables in the SCL program without explicitly declaring
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
SAS Guide to Applications Development.
Lengths of window variables are determined as follows:
SCL programs can define and use variables that do not have associated
controls or fields in the window. These variables are called nonwindow variables,
and they are used to hold values that users do not need to see. SCL programs
that do not have an associated window use only nonwindow variables. Nonwindow
variables are also referred to as program variables. Because nonwindow variables
are used only within an SCL program, they have no informat or format.
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 are created automatically when an SCL program compiles. These variables communicate information between an SCL program and an application, and you can use them in programs. System variables can be Character, Numeric, or Object data type variables. The Object data type facilitates compile-time checking for SCL programs that use dot notation to invoke methods and to access attributes for objects. Although the system variables _CFRAME_, _FRAME_, and _SELF_ are designated as object variables in Version 8 of SAS software, applications that were built with earlier releases and that use these variables will continue to work with Version 8.
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.
||modification or selection|
|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_;
_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_;
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.
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.