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
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;
read all var {investor y};
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;
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?
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;
read all var {investor y};
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;
Thanks for your help.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.