Calcite | Level 5

## matrix Product by IML

data a;

input investor \$ y;

cards;

fdcd1 0.006157039

fdcd2 0.001510721

fdcd3 0.35458659

fdcd4 -0.04071315

fdcd5 -0.01494467

fdcd6   -0.009

run;

The matrix is like this( Note: the colname of matrix is a mess of vector. Their orders are different).  How to give their Product?  Thanks!

fdcd1 fdcd3 fdcd2 fdcd5 fdcd4 fdcd6

0.79 0.01 1.09 3.75 0.82 0.43

1.4 0.23 0.86 0.88 1.44 1.19

0 0 0 0 0 0

0 0.09 0 0 0 0.02

0.33 0 0 0 0.33 0.29

0.28 0 0 0 0.27 0.42

0 0 0 0 0 0

0 0 0 0 0 0.04

0 0 0 0 0 0

0.14 0.19 0 0 0.14 0.1

0 0 0 0 0 0

0.19 0 0 0 0.19 0.17

0 0 0 0 0 0

0.12 0.1 0 0 0.12 0.15

0 0 0 0 0 0.06

0 0 0 0 0 0

0.1 0 0 0 0.1 0.09

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: matrix Product by IML

It looks like you want the product of the matrix (in the second part) with the vector (in the first part). The problem you are having is that the columns of the matrix are not in the same order as the elements in the vector.

Read in the investors and the y vector from data set A.  Then use the INVESTORS vector to specify the order of the variables when you read the matrix, which I assume is in a data set named M:

proc iml;
use a;
close a;

use m;
read all var investor into X;  /* read variables in order contained in INVESTOR */
close m;

v = X*y;   /* matrix-vector product */
print v;

3 REPLIES 3
Diamond | Level 26

## Re: matrix Product by IML

Normally I think of the "matrix product" as the multiplication of two (or more) matrices, but you only seem to have one matrix. Could you explain further what you want?

--
Paige Miller
SAS Super FREQ

## Re: matrix Product by IML

It looks like you want the product of the matrix (in the second part) with the vector (in the first part). The problem you are having is that the columns of the matrix are not in the same order as the elements in the vector.

Read in the investors and the y vector from data set A.  Then use the INVESTORS vector to specify the order of the variables when you read the matrix, which I assume is in a data set named M:

proc iml;
use a;
close a;

use m;
read all var investor into X;  /* read variables in order contained in INVESTOR */
close m;

v = X*y;   /* matrix-vector product */
print v;

Calcite | Level 5