In this example list[] contains the True and False values, and list2[] contains the equivalent list of 0's
and 1's.
(Credit to Billy)
[3.7] Replacement for Fill instruction in functions
The Fill instruction is useful for building vectors and arrays of constants. However, since Fill is not a
function, it cannot be used in 89/92+ functions. This can, though:
list▶mat(seq(val,i,1,nrow*ncol),ncol)
where val is the constant with which to fill the matrix, nrow is the number of rows, and ncol is the
number of columns. For example
list▶mat(seq(2,i,1,6),3)
returns this matrix
222
222
[3.8] Work-around for writing to data variable elements
There are no built-in instructions to write to single elements in data variables. This can be limiting,
since data variables are used in the statistics and regression functions. However, you can write to
elements indirectly with this procedure:
datalist(adata)
prgm
©Convert data variable to matrix
©31dec99/dburkett@infinet.com
©adata: contains data variable name as string
local alist1,alist2,amatrix
©Convert data variable 'adata' to one list for each column
#adata[1]→alist1
#adata[2]→alist2
©Convert lists to matrix
augment(list▶mat(alist1,1),list▶ mat(alist2,1))→amatrix
©Modify list or matrix elements as needed, for example:
3→amatrix[2,1]
4→amatrix[2,2]
©Convert lists to data variable
newdata #adata,amatrix
Endprgm
The basic idea is to convert the data variable to a matrix, change the elements as needed, then
convert the matrix back to a data variable. This program assumes that the data variable has two
3 - 4