Previous Page | Next Page

SAS Component Language Dictionary

SET



Links SAS table columns to SCL variables of the same name and data type
Category: SAS Table

Syntax
Details
Example
See Also

Syntax

CALL SET(table-id);

table-id

contains the identifier that was assigned when the table was opened. If table-id is invalid, the program halts.

Type: Numeric


Details

Using the SET routine can significantly reduce the coding required for accessing the values of variables for modification or verification. After a CALL SET, whenever a read operation is performed from the SAS table, the values of the SCL variables are set to the values of the corresponding SAS table columns. If the lengths do not match, then the values are truncated or padded as needed. When UPDATE or APPEND is called, the values that are written to the SAS table are the values of the SCL variables. If you do not use SET, then you must use GETVARC, GETVARN, PUTVARC, and PUTVARN to explicitly move values between table columns and SCL variables.

For each read/write operation that is performed on a SET SAS table, SCL loops through all the SAS table columns and updates the corresponding SCL variables. If the mapped SCL variables are only a small subset of the total SAS table columns, the looping could slow the process and prevent optimal performance. To enhance the performance of the application, you could open a SAS table as follows, using an option that limits the columns to only those to be set:

dsid=open('sasuser.employee (keep=age name)');
call set(dsid);

SET links only SCL variables that are accessible to the entire SCL program. SET does not link local variables, and using SET to link local variables in CLASS and USECLASS blocks may cause compilation errors.

As a general rule, use SET immediately following OPEN if you want to link table columns and SCL variables. Character variables that are associated with table columns must be declared with a DECLARE or LENGTH statement. Otherwise, the SCL compiler considers these variables to be numeric and thus sets them to missing instead of copying the appropriate character value from the table column.

If you use SET, do not use PUTVARN and PUTVARC for any variables that would be linked by SET. UPDATE and APPEND automatically move the data from the SCL data vector to the table data vector before writing the row to the physical file.

If a table column and a SCOM frame control have the same name, and if the table column has the same data type as the frame control's default attribute, SET links the frame control's default attribute with the table column.


Example

Automatically set the values of the SCL variables NAME and SALARY when a row is fetched for a window that contains the fields NAME and SALARY. The SAS table PERSONEL has three columns: NAME, SALARY and DEPT.

tableid=open('personel','i');
call set(tableid);
rc=fetchobs(tableid,10);


See Also

APPEND

FETCH

FETCHOBS

GETVARC and GETVARN

LOCATEC and LOCATEN

PUTVARC and PUTVARN

UPDATE

Previous Page | Next Page | Top of Page