Professional Documents
Culture Documents
0108 Data Step
0108 Data Step
Jerry Le Breton
Agenda
This is NOT a tutorial on SCL What is SCL? Why you ought to know How to mix Base SAS and SCL
What is SCL?
SCL (pre-V7) Screen Control Language SCL (V7+) SAS Component Language For on-line applications (with SAS/AF) Much wider usage for SCL SCL as another facility for the Base SAS programmer
SCL Features
Supports on-line applications Object oriented language - for code re-use in class libraries Extra coding features and functions
Dynamic arrays SCL Lists Other extra functionality
SAUSAG 16 August 2001 SCL for Base SAS Programmers 4
(2)
(3)
The previous SCL will run in an SCL program or a Data Step Faster as real SCL because compiled before execution
SCL Arrays
SCL supports, standard, static arrays
Fixed size array a(10) $20; Fixed type character or numeric
SAUSAG
SCL Arrays
(3)
Static arrays are fixed SCL supports dynamic arrays Special functions define dynamic arrays:
Declare char arrayname(*); Arrayname = makearray(10); rc = redim(arrayname, 20);
Extra array functions that only exist in SCL, e.g: asort - for array sorting copyarray comparearray
SAUSAG 16 August 2001 SCL for Base SAS Programmers 10
SCL Arrays
Equivalent SCL:
(4)
declare char types(*); declare num starts(*); declare num ends(*); ... types = makearray(1); starts = makearray(1); ends = makearray(1); ... fid = fopen(...); do while (fread(fid) = 0); ... if <this record for same person> then do; rc = redim(types, dim(types) + 1); types{dim(types} = allw_type; ... end;
SAUSAG 16 August 2001 SCL for Base SAS Programmers 11
SCL Lists
SCL Lists are really dynamic
elements added (& deleted) without redim elements can be different types elements can be sub-lists elements can have names
12
DOB
2098
(N )
A llo w an c e (L)
123
A llo w an c e
125
(L)
F red S m ith
13
Lists can be saved as SLIST catalog entries Alternative data structure to SAS data sets - for the right shaped data. Not suitable for large amounts of data - SCL lists are held in memory.
SAUSAG 16 August 2001 SCL for Base SAS Programmers 15
IN operator
array list{3} $10 ('cat','bird','dog'); i='dog' in ('cat','bird','dog'); /* i=3 in SCL i=1 in Data Step */ j='dog' in list; /* Only in SCL */
SAUSAG 16 August 2001 SCL for Base SAS Programmers 16
17
Summary
So why bother with SCL? Extra features: Dynamic arrays SCL Lists Other functions Greater flexibility Can be faster because already compiled ( Job Security?! )
19