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

Hello

 

I am writing a code in order to find an initial value for my optimization. For some reason, SAS keeps on giving me the following error 

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

I checked every single step, but can't find the error.

Please help!!!

 

Thank you
 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

It is always a good idea to post the log near the error, not just the error. In your case, the log says

2318
2319 f= m*log(alpha*lambda)+(lambda-1)*Sum1 +
2319! (alpha-1)*Sum2 + alpha*Sum3 +
2320 alpha *(n-m-Rq[+])*log(1-(X[m]**lambda));
2321
2322
2323
2324 return( -f );
2324! /* return -f so that extrema are maxima */
2325 finish;
2329 f = Camel(KK); ERROR: (execution) Matrices do not conform to the operation. operation : * at line 2319 column 22 operands : alpha, lambda alpha 10000 rows 1 col (numeric) lambda 10000 rows 1 col (numeric) statement : ASSIGN at line 2319 column 8 traceback : module CAMEL at line 2319 column 8 NOTE: Paused in module CAMEL.

"do not conform" for the '*' operation means that you are trying to perform matrix multiplication, but the matrices are the wrong dimension. By looking at the line number, you can see that matrix multiplication is not defined between two Nx1 vectors. Fortunately, you showed in a comment that you copied code from https://blogs.sas.com/content/iml/2014/06/11/initial-guess-for-optimization.html, and you can check that blog post to see that the author used the '#' operator (not the '*' operator) to perform elementwise multiplication of two vectors.  

 

I don't know which of your symbols represent vectors vs scalars, but you can use # for multiplication when you define the function, like this:

       f= m#log(alpha#lambda)+(lambda-1)#Sum1 + (alpha-1)#Sum2 + alpha#Sum3 + 
                                                           alpha#(n-m-Rq[+])#log(1-(X[m]**lambda));

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

It is always a good idea to post the log near the error, not just the error. In your case, the log says

2318
2319 f= m*log(alpha*lambda)+(lambda-1)*Sum1 +
2319! (alpha-1)*Sum2 + alpha*Sum3 +
2320 alpha *(n-m-Rq[+])*log(1-(X[m]**lambda));
2321
2322
2323
2324 return( -f );
2324! /* return -f so that extrema are maxima */
2325 finish;
2329 f = Camel(KK); ERROR: (execution) Matrices do not conform to the operation. operation : * at line 2319 column 22 operands : alpha, lambda alpha 10000 rows 1 col (numeric) lambda 10000 rows 1 col (numeric) statement : ASSIGN at line 2319 column 8 traceback : module CAMEL at line 2319 column 8 NOTE: Paused in module CAMEL.

"do not conform" for the '*' operation means that you are trying to perform matrix multiplication, but the matrices are the wrong dimension. By looking at the line number, you can see that matrix multiplication is not defined between two Nx1 vectors. Fortunately, you showed in a comment that you copied code from https://blogs.sas.com/content/iml/2014/06/11/initial-guess-for-optimization.html, and you can check that blog post to see that the author used the '#' operator (not the '*' operator) to perform elementwise multiplication of two vectors.  

 

I don't know which of your symbols represent vectors vs scalars, but you can use # for multiplication when you define the function, like this:

       f= m#log(alpha#lambda)+(lambda-1)#Sum1 + (alpha-1)#Sum2 + alpha#Sum3 + 
                                                           alpha#(n-m-Rq[+])#log(1-(X[m]**lambda));

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 343 views
  • 1 like
  • 2 in conversation