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
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));
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));
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.