I am not sure what you mean by the line of code that starts doit[i,j]=... however the code below that can be made to work. The problems are:
the do loops allow i to be equal to j - you probably do not want the zeros that will result from this.
either group_mean or groupmean is a typo.
If you still cannot make it work, then please show us the messages that you are getting in the log.
In general it is a bad habit to grow matrices by concatenation inside a loop - this is very inefficient in terms of memory use. For a=3 you will probably not notice, but similar code with a=1000 would grind to a halt.
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.