Chapter Contents |
Previous |
Next |
INSERTC, INSERTL, INSERTN, and INSERTO |
Category: | List |
Syntax | |
Details | |
Examples | |
Example 1: Using the INSERTC Function | |
Example 2: Using the INSERTL Function | |
Example 3: Using the INSERTN Function | |
Example 4: Using the INSERTO Function | |
See Also |
Syntax |
rc=INSERTC(list-id,cval<,index<,name>>); |
rc=INSERTL(list-id,sublist-id<,index<name>>); |
rc=INSERTN(list-id,nval<,index<name>>); |
rc=INSERTO(list-id,object-id<,index<name>>); |
Type: Numeric
Type: Numeric or List
Type: Character
Type: Numeric
Type: Numeric
Type: Numeric or Object
Type: Numeric
Type: Character
Details |
The item is inserted such that after you insert an item at position index, you can retrieve it from position index with any of these functions.
These functions do not make a copy of the list. The insertion is performed in place. You can append an item to an SCL list of length n by inserting at index=n+1 or at index=-1.
Note: The return value of these
functions is not used to indicate
whether an error has been detected. When an error occurs, the program simply
halts.
An error condition results if
You can use HASATTR to check the attributes of a list or list item. To change attributes, use SETLATTR.
Examples |
Insert CANADA
as the third item in the list:
listid=insertc(listid,'CANADA',3);After this insertion, return the value that was third in the list before the insertion of
CANADA
shifted the value from the third to the fourth position:
cval=getitemc(listid,4);
Insert the sublist NEWLIST as the third item from the end of the list:
listid=insertl(listid,newlist,-3);
Assume that the list MYLIST contains four items, named A
,
B
, C
, and D
, with the values 1, 4, 9, and 16, respectively. Insert two
new items: a string at the default position 1 (the beginning of the list),
and a number at position -1 (the end of the list). The new number is
given the name E
.
call putlist(mylist,'Before: ',0); mylist=insertc(mylist,'Squares'); mylist=insertn(mylist,25, -1,'E'); call putlist(mylist,'After: ',0);This program produces the following output:
Before: (A=1 B=4 C=9 D=16 )[3] After: ('Squares' A=1 B=4 C=9 D=16 E=25 )[3]
Note: [3] is the list identifier
that was assigned when this example was run and may be different each time
the example is run.
Create the list MYLIST, insert the item whose identifier is stored in the
variable MYOBJECT, and assign the name My Object
to the item:
declare sashelp.fsp.object myobject, =_new_ sashelp.fsp.object(), list mylist; mylist=makelist(); rc=inserto(mylist,myobj,-1,'My Object');
See Also |
GETITEMC, GETITEML, GETITEMN, and GETITEMO
GETNITEMC, GETNITEML, GETNITEMN, and GETNITEMO
SETITEMC, SETITEML, SETITEMN, and SETITEMO
SETNITEMC, SETNITEML, SETNITEMN, and SETNITEMO
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.