SCL Lists |
You can initialize an SCL list
in a DCL statement. For example, to create a list with the constants 1, 2, 'a', 3, 'b', and 'c', you can declare the list as follows:
DCL list mylist={1,2,'a',3,'b','c'};Your list may also contain sublists. For example:
DCL list mylist={1,2,'a',mysub={'A','B','C', 3,'b','c'}};
When you use the DECLARE statement to initialize an SCL list, you can use either braces ({ and }) or brackets ([ and ]) to enclose a series of list items. For example, both of the following list definitions are valid:
dcl list x = {1,2,3}; dcl list z = [4,5,6];
in an assignment statement after you have declared the list. For example, the following assignment statement initializes the employee list with an employee ID, name, and office location. The location is a sublist.
DCL list employee; employee = {id=9999, name='Thomas', locate={bldg='R', room='4321'}};
by specifying the InitialValue attribute when you create a class. In the following example, the class InitVal initializes three list attributes, which also contain sublists.
class work.a.InitVal.class; public list list1 / (InitialValue= {COPY={ POPMENUTEXT='Copy here', ENABLED='Yes', METHOD='_drop' }, MOVE={ POPMENUTEXT='Move here', ENABLED='Yes', METHOD='_drop' } } ); public list list2 / (initialValue= {1,2,3,{'abc','def',{1,2,'abc'},3},'def'}); public list list3 / (initialValue= {id=888,name=Rob, answers={mchoice={'a','c','b','e'}, math={1,4,8,9,}} } );For more information about creating classes, see CLASS.
Note: Even if you initialize a list with a DCL or assignment statement or with the initialValue attribute (rather than using one of the INSERT functions), you must still explicitly delete the list as described in Deleting Lists and List Items from SCL Lists.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.