SAS Component Language (SCL)

Introduction to SCL

SAS Component Language (SCL) is the programming language that controls SAS/AF applications (including frames and the controls on frames).
SCL programs are stored in SCL entries, separately from frames. Because of this separation, SCL entries can be accessed by more than one frame, which means that an SCL program or function can be written once and used many times.
SCL is an object-oriented programming language that was designed to facilitate the development of interactive SAS applications. SCL enables you to perform the following tasks:
  • calculate and validate field values that are based on user input
  • change the attributes of components on a frame at run time
  • execute methods of components on a frame
  • link to other SAS catalog entries, including other SCL entries and frames
  • submit SAS programs
  • read from and write to SAS tables, SAS catalog entries, and external files
This document does not cover all of these topics. For complete reference information about SCL, refer to the SAS Component Language: Reference (the complete text of which is in the SAS/AF help).

Frame SCL

Frame SCL is an SCL entry that is associated with a particular frame (and is the only type of SCL that is used in the example later in this document). Frame SCL is typically used to control a frame and the components on that frame.
For example, in the following diagram, the SCL code that is marked 'A' is the initialization code for the frame, and executes before the frame is displayed. This code specifies that the model that is associated with the List Box look in the SASHELP library for tables. The code that is marked 'B' is executed when a selection is made from the List Box. When a table is selected, the table is displayed in the Table Viewer.
Frame SCL Controls a Frame
Frame SCL controls a frame
You can view and edit the frame SCL for any frame that you have open and active by selecting Viewthen selectFrame SCL, or by selecting Frame SCL from the frame's pop-up menu.
Although you can open and edit frame SCL just as you can an SCL program that is not associated with a frame, you should only compile frame SCL from its associated frame (see Compiling Applications for more information).

When Frame SCL Is Not Required

A frame does not require an SCL program. Some components that you can add to a frame are designed to perform tasks without additional SCL code. For example, you can add a Push Button control to a frame and set its commandOnClick attribute to end; (with the semicolon). The result is that when a user clicks the button, the END command executes, closing the frame that the button is on. Instead of compiling a frame that has no SCL code (which will produce an error), just save it.

When Frame SCL Is Required

Frame SCL is required if you need to do any of the following:
  • link to other SCL entries or frames.
  • submit SAS programs.
  • modify a component's properties at run time. For example, changing the appearance of a control after a user enters input.
  • execute a method on a component.
  • validate the selections that a user makes.