How would I write a subrountine that takes 2 parameters (a constant and a square matrix). Then adds that constant to the every element of the diagonal of the matrix, and passes the results back in a new parameter?
Then out puts the new matrix after the subtracted constant
I have the general idea but getting stuck on the diagonal part.
A quick way to add a constant to the diagonal elements of a matrix:
/* add B to diagonal of a square matrix A */
C = A + diag( j(nrow(A), 1, B) );
SAS INNOVATE 2024
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.