Hi:
Scott has given you some good references. I also find that this is a good introduction to the Macro facility for beginners:
http://www2.sas.com/proceedings/sugi28/056-28.pdf
The essence of the SAS macro facility is text substitution -- either at the statement level or the program level or at the single keyword or variable name level. Think of the SAS Macro Facility as a way to -generate- SAS code. The Macro facility, in and of itself, does not -execute- any code. It merely resolves macro variable references and macro program references into code which -can- be executed by the SAS compiler.
In addition to Scott's links and my introductory link, there are many, many previous postings in these forums and in SAS Global Forum papers and other user group papers -- everything from basic macro tutorials to examples of advanced macro applications.
There is no good way for anyone in the forum, to design, in detail or explain in detail the solution to your problem. You have to understand the macro facility a bit better in order to understand how it works and how you might apply usage of the Macro facility to solve your problem.
The paper I referenced at the beginning will show you the basics of how to start with a simple macro variable and will lead you through 9 steps until you understand how to write a simple macro program. The key to using the Macro facility is to start with a -WORKING- SAS program -- one that you know works and know that it needs to be run repetitively or one that needs to be generalized to run against differeing inputs (to name just a few of the reasons that folks use SAS macro programs). That way, you have a program that produces that desired results -- and against which, you can verify that your macro program is working correctly.
Good luck!
cynthia