You might want to include a description of what you mean -- I'm guessing it's this classic problem, sometimes assigned as a programming learning exercise.
If it is an assignment....do you have examples of what you've tried? There are probably elegant solutions in SAS/IML, but I think a DATA step approach could work as well.
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!