Our Macro Reference Manual provides a great deal of information and examples for programming Macros.
We highly recommend reviewing the Manual, which can be downloaded from our Support Center here: https://maplesystems.com/support-center/manuals-guides
There is also a very helpful tutorial video on building macros here, which features examples of declaring a variable and programming various statements: