Reputation: 866
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.
Upvotes: 0
Views: 266
Reputation: 63424
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:
[1,3,5]
and matrix2 is the following matrix:
[1,2,3,4,
4,5,6,7,
8,9,10,11,
13,14,15,16]
Now,
matrix1`*matrix2
is illegal - matrix1` has 3 rows (transposed) and matrix2 has 4 columns. So:
matrix1`*matrix2[,1:3]
will now be legal, yielding the matrix product of matrix1` by the first 3 columns of matrix2.
Upvotes: 1