51). Have you used macros? For what purpose you have used?

Yes I have, I used macros in creating analysis datasets and tables where it is necessary to make a small change through out the program and where it is necessary to use the code again and again.

52). How would you invoke a macro?

After I have defined a macro I can invoke it by adding the percent sign prefix to its name like this: % macro name a semicolon is not required when invoking a macro, though adding one generally does no harm.

53). How we can call macros with in data step?

We can call the macro with CALLSYMPUT

54). How do u identify a macro variable?

Ampersand (&)

55). How do you define the end of a macro?

The end of the macro is defined by %Mend Statement

56). For what purposes have you used SAS macros?

If we want use a program step for executing to execute the same Proc step on multiple data sets. We can accomplish repetitive tasks quickly and efficiently. A macro program can be reused many times. Parameters passed to the macro program customize the results without having to change the code within the macro program. Macros in SAS make a small change in the program and have SAS echo that change thought that program.

57). What is the difference between %LOCAL and %GLOBAL?

% Local is a macro variable defined inside a macro.%Global is a macro variable defined in open code (outside the macro or can use anywhere).

58). How long can a macro variable be? A token?

A component of SAS known as the word scanner breaks the program text into fundamental units called tokens.· Tokens are passed on demand to the compiler.· The compiler then requests token until it receives a semicolon.· Then the compiler performs the syntax check on the statement.

59). If you use a SYMPUT in a DATA step, when and where can you use the macro variable?

Macro variable is used inside the Call Symput statement and is enclosed in quotes.

60). What do you code to create a macro? End one?

%MACRO and %MEND

61). What is the difference between %PUT and SYMBOLGEN?

%PUT is used to display user defined messages on log window after execution of a program where as % SYMBOLGEN is used to print the value of a macro variable resolved, on log window.

62). How do you add a number to a macro variable?

Using %eval function

63). Can you execute a macro within a macro? Describe.

Yes, Such macros are called nested macros. They can be obtained by using symget and call symput macros.

64). 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.

65). 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.

66). 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;

67). 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;

68). How we can call macros with in data step?

We can call the macro with CALLSYMPUT, Proc SQL and %LET statement.

69). Tell me about call symput?

CALL SYMPUT takes a value from a data step and assigns it to a macro variable. I can then use this macro variable in later steps. To assign a value to a single macro variable, I use CALL SYMPUT with this general form:

CALL SYMPUT (“macro-variable-name”, value);
Where macro-variable-name, enclosed in quotation marks, is the name of a macro variable, either new or old, and value is the value I want to assign to that macro variable. Value can be the name of a variable whose value SAS will use, or it can be a constant value enclosed quotation marks.

CALL SYMPUT is often used in if-then statements such as this:
If age>=18 then call symput (“status”,”adult”);
Else call symput (“status”,”minor”);
These statements create a macro variable named &status and assign to it a value of either adult or minor depending on the variable age.

Caution: We cannot create a macro variable with CALL SYMPUT and use it in the same data step because SAS does not assign a value to the macro variable until the data step executes. Data steps executes when SAS encounters a step boundary such as a subsequent data, proc, or run statement.

70). Tell me about % include and % eval?

The %include statement, despite its percent sign, is not a macro statement and is always executed in SAS, though it can be conditionally executed in a macro.

It can be used to setting up a macro library. But this is a least approach. The use of %include does not actually set up a library. The %include statement points to a file and when it executed the indicated file (be it a full program, macro definition, or a statement fragment) is inserted into the calling program at the location of the call. When using the %include building a macro library, the included file will usually contain one or more macro definitions.

%EVAL is a widely used yet frequently misunderstood SAS(r) macro language function due to its seemingly simple form. However, when its actual argument is a complex macro expression interlaced with special characters, mixed arithmetic and logical operators, or macro quotation functions, its usage and result become elusive and problematic. %IF condition in macro is evaluated by %eval, to reduce it to true or false.