I want to build a list containing multiple subitems at the same level so that I have what is equivalent to an array of lists. The code is:
proc iml ; package load listutil ;
L = [] ;
L = L || [ #'1'=[] ] ;
L$1 = [ #'1.1'=[] ] ;
call listprint( L$'1'$'1.1' ) ;
L$1 = L$1 || [ 1, #index=1 ] ;
L$1 = L$1 || [ 2, #index=2 ] ;
L$1 = L$1 || [ 2, #index2=2 ] ;
call struct(L) ;
quit ;
proc iml ; package load listutil ;
L = [] ;
L = L || [ #'1'=[] ] ;
L$1 = [ #'1.1'=[] ] ;
call listprint( L$'1'$'1.1' ) ;
L$1 = L$1 || [ 1, #index=1 ] ;
L$1 = L$1 || [ 2, #index=2 ] ;
L$1 = L$1 || [ 2, #index2=2 ] ;
call struct(L) ;
quit ;
proc iml ; package load listutil ;
L = [] ;
L = L || [ #'1'=[] ] ;
L$1 = [ #'1.1'=[] ] ;
call listprint( L$'1'$'1.1' ) ;
L$1 = L$1 || [ 1, #index=1 ] ;
L$1 = L$1 || [ 2, #index=2 ] ;
L$1 = L$1 || [ 2, #index2=2 ] ;
L$1 = L$1 || [ 2, 3 ] ;
L$1 = L$1 || [ 2, 3 ] ;
call struct(L) ;
quit ;
The log displays an error:
72 L = [] ;
73 L = L || [ #'1'=[] ] ;
74 L$1 = [ #'1.1'=[] ] ;
75 call listprint( L$'1'$'1.1' ) ;
76 L$1 = L$1 || [ 1, #index=1 ] ;
77 L$1 = L$1 || [ 2, #index=2 ] ;
ERROR: Conflicting item names were found in the list concatenation.
operation : || at line 77 column 11
operands : _TEM1001, _TEM1002
_TEM1001 3 items (list)
_TEM1002 2 items (list)
statement : ASSIGN at line 77 column 1
78 L$1 = L$1 || [ 2, #index2=2 ] ;
79 call struct(L) ;
Note that the same operation in line 78 is acceptable even though the first item in the right argument to the concatenation operator, 2, is the same as the first item in the statement on line 77. The named items, 'index' and 'index2', are different. Furthermore, if the example is extended to
proc iml ; package load listutil ;
L = [] ;
L = L || [ #'1'=[] ] ;
L$1 = [ #'1.1'=[] ] ;
call listprint( L$'1'$'1.1' ) ;
L$1 = L$1 || [ 1, #index=1 ] ;
L$1 = L$1 || [ 2, #index=2 ] ;
L$1 = L$1 || [ 2, #index2=2 ] ;
L$1 = L$1 || [ 2, 3 ] ;
L$1 = L$1 || [ 2, 3 ] ;
call struct(L) ;
quit ;
then we will observe that the last two concatenations are accepted even though the items [ 2, 3 ] are identical. Why are identical numeric arguments accepted for list items but named items are required to be distinguished?