71). Describe the ways in which you can create macro variables?
There are the 5 ways to create macro variables:
72). Tell me more about the parameters in macro?
Parameters are macro variables whose value you set when you invoke a macro. To add the parameters to a macro, you simply name the macro vars names in parenthesis in the %macro statement.
%MACRO macro-name (parameter-1= , parameter-2= , ……parameter-n = );
73). What is the maximum length of the macro variable?
32 characters long.
74). Automatic variables for macro?
Every time we invoke SAS, the macro processor automatically creates certain macro var. eg: &sysdate &sysday.
75). What system options would you use to help debug a macro?
Debugging a Macro with SAS System Options. The SAS System offers users a number of useful system options to help debug macro issues and problems. The results associated with using macro options are automatically displayed on the SAS Log. Specific options related to macro debugging appear in alphabetical order in the table below.SAS Option Description:
MEMRPT Specifies that memory usage statistics be displayed on the SAS Log.
MERROR: SAS will issue warning if we invoke a macro that SAS didn’t find. Presents Warning Messages when there are misspellings or when an undefined macro is called.
SERROR: SAS will issue warning if we use a macro variable that SAS can’t find.
MLOGIC: SAS prints details about the execution of the macros in the log.
MPRINT: Displays SAS statements generated by macro execution are traced on the SAS Log for debugging purposes.
SYMBOLGEN: SAS prints the value of macro variables in log and also displays text from expanding macro variables to the SAS Log.
76). If you need the value of a variable rather than the variable itself what would you use to load the value to a macro variable?
If we need a value of a macro variable then we must define it in such terms so that we can call them everywhere in the program. Define it as Global. There are different ways of assigning a global variable. Simplest method is %LET.
Ex:A, is macro variable. Use following statement to assign the value of a rather than the variable itselfe.g.%Let A=xyzx=”&A”;This will assign “xyz” to x, not the variable xyz to x.
77). Can you execute macro within another macro? If so, how would SAS know where the current macro ended and the new one began?
Yes, I can execute macro within a macro, what we call it as nesting of macros, which is allowed. Every macro’s beginning is identified the keyword %macro and end with %mend.
78). How are parameters passed to a macro?
A macro variable defined in parentheses in a %MACRO statement is a macro parameter. Macro parameters allow you to pass information into a macro. Here is a simple example: %macro plot(yvar= ,xvar= ); proc plot; plot &yvar*&xvar; run;%mend plot;
79). How would you code a macro statement to produce information on the SAS log?
This statement can be coded anywhere?OPTIONS, MPRINT MLOGIC MERROR SYMBOLGEN;
80). How we can call macros with in data step?
We can call the macro with CALLSYMPUT, Proc SQL and %LET statement.