I have a single line/multi column matrix, multiplied by a square matrix. SAS gives me a single line result. So far, from what I remember from college math, and asking people, okay.
But the line from SAS that does it is this one:
fieldA = matrix1`*matrix2[,1:fieldB]
while I understand “fieldA = matrix1`*matrix2”, I have no idea what [,1:fieldB] does, and I can’t seem to find any document that explains it.
matrix2[,1:fieldB]is subsetting matrix2. It includes all rows of matrix2, and only those columns that are included in the list 1:fieldB. Presumably fieldB identifies the number of columns in matrix1 (which become rows when transposed) so the * works [matrix1'rows must equal matrix2 columns for the operation to be legal].For example, imagine matrix1 is the following matrix:
and matrix2 is the following matrix:
Now,
is illegal – matrix1` has 3 rows (transposed) and matrix2 has 4 columns. So:
will now be legal, yielding the matrix product of matrix1` by the first 3 columns of matrix2.