Hi:
Interesting perspective.
Personally, I do not think the iPad's "text substitution" routine is a good metaphor for what the macro facility does. I do not find any "touch screen" examples that accurately illustrate the capabilities of the macro facility. Nor do I think, offhand, of any "voice recognition" software example that is a good metaphor for what the macro facility does.
The closest computer based metaphor that I can some up with is programmable keyboard shortcuts -- so I might, in my word processor, set up F1 to always insert "supercalifragilisticexpealidocious" wherever my cursor was placed in a word processing document or if I had a SEARCH and REPLACE routine set up in Word...to search for ~XXX~ and replace that string with the some other string.
The fundamental idea of "text substitution" is the first hurdle for "macro newbies" and I think that this section from the documentation explains the basics:
from the documentation:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#getstart.htm
This entire section is a direct quote from the macro documentation. The highlights were added by me.
[beginquote]
When you use a macro facility name in a SAS program or from a command prompt, the macro facility generates SAS statements and commands as needed. The rest of SAS receives those statements and uses them in the same way it uses the ones you enter in the standard manner.
The macro facility has two components:
macro processor is the portion of SAS that does the work
macro language is the syntax that you use to communicate with the macro processor
When SAS compiles program text, two delimiters trigger macro processor activity:
&name refers to a macro variable. "Replacing Text Strings Using Macro Variables" explains how to create a macro variable. The form &name is called a macro variable reference.
%name refers to a macro. "Generating SAS Code Using Macros" explains how to create a macro. The form %name is called a macro call.
The text substitution produced by the macro processor is completed before the program text is compiled and executed. The macro facility uses statements and functions that resemble the statements and functions that you use in the DATA step. An important difference, however, is that macro language elements can enable only text substitution and are not present during program or command execution.
[endquote]
If people don't understand this last sentence, I find this to be a good documentation site that walks through a simple program and has pictures that show the process of text substitution:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071824.htm
When you move beyond text substitution with &MACVAR references and %LET, then there are other documentation sites that explain, in great detail, how macro program calls are resolved and what is generated when you call a macro program. On this documentation site
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001072042.htm
It says:
[beginquote]
How the Macro Processor Executes a Compiled Macro
Macro execution begins with the macro processor opening the SASMACR catalog to read the appropriate macro entry.
As the macro processor executes the compiled instructions in the macro entry, it performs a series of simple repetitive actions. During macro execution, the macro processor does the following:
--executes compiled macro program instructions
--places noncompiled constant text on the input stack
--waits for the word scanner to process the generated text
--resumes executing compiled macro program instructions
[endquote]
Again, I see no iPad, voice recognition or touch screen analogy possibilities in that explanation.
And, I find this "Summary of Macro Processing" explanation in the documentation
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001072045.htm
to be VERY clear:
[beginquote]
Summary of Macro Processing
The previous sections illustrate the relationship between macro compilation and execution and DATA step compilation and execution. The relationship contains a pattern of simple repetitive actions.
These actions begin when text is submitted to the input stack and the word scanner begins tokenization. At times the word scanner waits for the macro processor to perform an activity, such as searching the symbol tables or compiling a macro definition. If the macro processor generates text during its activity, then it pauses while the word scanner tokenizes the text and sends the tokens to the appropriate target. These tokens might trigger other actions in parts of SAS, such as the DATA step compiler, the command processor, or a SAS procedure. If any of these actions occur, the macro processor waits for these actions to be completed before resuming its activity. When the macro processor stops, the word scanner resumes tokenization. This process continues until the entire program has been processed.
[endquote]
cynthia
...whose sweaters do NOT smell like the stuffy basement of an old house
😉