While working with the DO loop function I encountered another problem;) I'd like to create several matrices with the help of the DO loop function but I'm still struggling with the matrices' names. Is it possible to assign a matrix name via the DO loop function as well?
Sometimes people THINK they need to do this because they are trying to wrap SAS/IML statements within a macro loop, which is rarely necessary. Instead, you can use the SAS/IML language itself to perform whatever the macro loop is doing.
You didn't post an example, but one common programming technique is to have all of the x vars in an nx10 matrix, where each column is a variable.
Then the following statements form a matrix m where each column is what you want:
y = j(n,1,0) || x; /* temp: append column of zeros */
m = y[,2:11] - y[,1:10];
Another alternative, if you don't need the whole matrix, is to loop:
do i = 1 to 10;
if i = 1 then m=x[,i];
else m = x[,i] - x[,i-1];
/* do something with m, which is m_i in your notation */
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.