BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
freeliu
Calcite | Level 5

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
Rick_SAS
SAS Super FREQ

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;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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
Rick_SAS
SAS Super FREQ

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;

freeliu
Calcite | Level 5

Thanks for your help.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 1448 views
  • 0 likes
  • 3 in conversation