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

Hi everyone. I have a question regarding multiplying matrices. I already read Interpreting PROC IML error messages: Matrices do not conform to the operation suggested in other boards and I still do not understand why I get this message. I understand that if I want to multiply xbeta = x # beta; the number of columns in X have to be equal to the rows in beta, right? I am running SAS 9.4

This is part of my code:

xbeta = x#beta;

se= sqrt (vecdiag(x#cov#x`));

lower =xbeta   - (1.96 # se);

upper =xbeta   + (1.96 # se);

When I run the operation I get this on the log:

ERROR: (execution) Matrices do not conform to the operation.

operation : # at line 15164 column 14

operands  : X, BETA

X    502 rows      6 cols    (numeric)

BETA      6 rows      1 col     (numeric)

And also when I try to perform this operation x#cov

operation : # at line 15164 column 80

operands  : X, COV

X    502 rows      6 cols    (numeric)

COV      6 rows      6 cols    (numeric)

What am I doing wrong? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Matrix multiplication does not support missing values.  If you are trying to mimic the usual OLS regression, you should remove the rows with missing values. This article might be useful:http://blogs.sas.com/content/iml/2015/02/23/complete-cases.html

View solution in original post

4 REPLIES 4
gergely_batho
SAS Employee

# is elementwise multiplication.

* is matrix multiplication

AM2323
Calcite | Level 5

When I change # to * I get the following error.

ERROR: (execution) Invalid argument or operand; contains missing values.

operation : * at line 15164 column 14

operands  : X, BETA

X    502 rows      6 cols    (numeric)

BETA      6 rows      1 col     (numeric)

Rick_SAS
SAS Super FREQ

Matrix multiplication does not support missing values.  If you are trying to mimic the usual OLS regression, you should remove the rows with missing values. This article might be useful:http://blogs.sas.com/content/iml/2015/02/23/complete-cases.html

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
  • 4 replies
  • 3739 views
  • 3 likes
  • 3 in conversation