Chapter Contents |
Previous |
Next |
LENGTH |
Category: | Declarative Statement |
Comparisons: | SAS Statement with limitations in SCL |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
LENGTH<variable-list><DEFAULT=n>; |
Type: Character
Type: Numeric
Details |
In SCL, LENGTH is a declarative statement and can be used only to set the lengths of nonwindow variables. If you attempt to specify a length for a window variable, a compile error occurs.
You typically place LENGTH statements at the beginning of a program, before the first labeled section. A compiler error occurs if you attempt to place a LENGTH statement within a DO group or within a conditional clause.
You can use the LENGTH statement to reduce the amount of memory required for storing character-type nonwindow variables. For example, if your program assigns only single-character values to the variable CODE, and if the default length of character variables is 200, then you can save 199 bytes of storage space by defining the length of the variable explicitly in the SCL program. To do so, use a statement like the following:
length code $ 1;
For details about the LENGTH statement in the base SAS language, see SAS Language Reference: Dictionary .
Example |
Set the maximum length of all character variables that are not defined by a LENGTH statement to 150:
length default=150; length a $ 8; INIT: b=''; max_a=mlength(a); max_b=mlength(b); put max_a= max_b=; return;The output is:
max_a=8 max_b=150
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.