Desktop productivity for business analysts and programmers

Multiply matrix and vector with proc iml

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

Multiply matrix and vector with proc iml

Hello,

 

I am trying to multiply a matrix and a vector with proc iml, but I never used it,.

 

Basically, I already have the two datasets that I need, one MATRIX and one VECTOR.

 

I simply want the resulting vector of the multiplication of MATRIX*VECTOR in a new dataset with one variable named RESULT.

 

 

 


Accepted Solutions
Solution
‎12-20-2017 10:16 AM
Super User
Posts: 10,610

Re: Multiply matrix and vector with proc iml

Better post is at IML forum, since it is a IML question.

 

data matrix;
 set sashelp.class;
 keep age weight height;
run;
data vector;
 do vector=1 to 3;
  output;
 end;
run;

proc iml;
use matrix;
read all var _num_ into matrix;
close;
use vector;
read all var {vector};
close;

result=matrix*vector;

create result var {result};
append;
close;
quit;

View solution in original post


All Replies
PROC Star
Posts: 1,262

Re: Multiply matrix and vector with proc iml

Here's an introductory resource to PROC IML that I hope you'll find helpful. Rick also publishes "The DO Loop" blog for SAS.

 

http://support.sas.com/resources/papers/proceedings13/144-2013.pdf

 

In the future, I suggest you post IML questions to the Analytics / SAS/IML area. The Enterprise Guide area tends to get questions about the EG interface, and the IML folks don't tend to watch it.

 

Tom

Contributor
Posts: 25

Re: Multiply matrix and vector with proc iml

Thank you, will do!
Solution
‎12-20-2017 10:16 AM
Super User
Posts: 10,610

Re: Multiply matrix and vector with proc iml

Better post is at IML forum, since it is a IML question.

 

data matrix;
 set sashelp.class;
 keep age weight height;
run;
data vector;
 do vector=1 to 3;
  output;
 end;
run;

proc iml;
use matrix;
read all var _num_ into matrix;
close;
use vector;
read all var {vector};
close;

result=matrix*vector;

create result var {result};
append;
close;
quit;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 3 in conversation