Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What Is Auto Call Macro And How To Create A Auto Call Macro? What Is The Use Of It? How To Use It In Sas With Macros?

Answer»

SAS ENABLES the user to call macros that have been stored as SAS programs.

The AUTO call macro facility allows users to access the same macro code from MULTIPLE SAS programs. Rather than having the same macro code for in each program where the code is required, with an autocall macro, the code is in one location. This permits faster updates and better consistency across all the programs.Macro set-up:The fist step is to set-up a program that contains a macro, desired to be used in multiple programs. Although the program MAY contain other macros and/or OPEN code, it is advised to include only one macro.

Set MAUTOSOURSE and SASAUTOS:

Before one can use the autocall macro within a SAS program, The MAUTOSOURSE option must be set open and the SASAUTOS option should be assigned. The MAUTOSOURSE option indicates to SAS that the autocall facility is to be activated. The SASAUTOS option tells SAS where to look for the macros.

For ex: sasauto=’g:busmeasinternalmacro’.

SAS Enables the user to call macros that have been stored as SAS programs.

The auto call macro facility allows users to access the same macro code from multiple SAS programs. Rather than having the same macro code for in each program where the code is required, with an autocall macro, the code is in one location. This permits faster updates and better consistency across all the programs.Macro set-up:The fist step is to set-up a program that contains a macro, desired to be used in multiple programs. Although the program may contain other macros and/or open code, it is advised to include only one macro.

Set MAUTOSOURSE and SASAUTOS:

Before one can use the autocall macro within a SAS program, The MAUTOSOURSE option must be set open and the SASAUTOS option should be assigned. The MAUTOSOURSE option indicates to SAS that the autocall facility is to be activated. The SASAUTOS option tells SAS where to look for the macros.

For ex: sasauto=’g:busmeasinternalmacro’.

2.

Automatic Variables For Macro?

Answer»

EVERY TIME we invoke SAS, the macro PROCESSOR automatically creates certain macro var.

eg: &sysdate &sysday.

Every time we invoke SAS, the macro processor automatically creates certain macro var.

eg: &sysdate &sysday.

3.

Tell Me More About The Parameters In Macro?

Answer»

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.

Syntax:

%MACRO macro-name (parameter-1= , parameter-2= , ……parameter-n = );

macro-text%;

%MEND macro-name;

%macro_name(par1,par2,....parn);

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.

Syntax:

%MACRO macro-name (parameter-1= , parameter-2= , ……parameter-n = );

macro-text%;

%MEND macro-name;

%macro_name(par1,par2,....parn);

4.

Describe The Ways In Which You Can Create Macro Variables?

Answer»

There are the 5 WAYS to CREATE macro VARIABLES:

  1. %Let
  2. %Global
  3. Call Symput
  4. Proc SQl into CLAUSE
  5. Macro Parameters.

There are the 5 ways to create macro variables:

5.

Tell Me About % Include And % Eval?

Answer»

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.

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.

6.

How We Can Call Macros With In Data Step?

Answer»

We can call the MACRO with

CALL SYMPUT,

Proc SQL ,

%LET STATEMENT. and macro parameters.

We can call the macro with

CALL SYMPUT,

Proc SQL ,

%LET statement. and macro parameters.

7.

How Would You Code A Macro Statement To Produce Information On The Sas Log? This Statement Can Be Coded Anywhere?

Answer»

OPTIONS MPRINT MLOGIC MERROR SYMBOLGEN.

OPTIONS MPRINT MLOGIC MERROR SYMBOLGEN.

8.

Can You Execute Macro Within Another Macro? If So, How Would Sas Know Where The Current Macro Ended And The New One Began?

Answer»

YES, I can execute macro within a macro, we call it as NESTING of macros, which is ALLOWED, Every macro's beginning is identified the keyword %macro and end with %mend.

Yes, I can execute macro within a macro, we call it as nesting of macros, which is allowed, Every macro's beginning is identified the keyword %macro and end with %mend.

9.

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?

Answer»

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 itself

%Let A=XYZ; %put x="&A";

This will assign "xyz" to x, not the variable xyz to x.

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 itself

%Let A=xyz; %put x="&A";

This will assign "xyz" to x, not the variable xyz to x.

10.

Can You Execute A Macro Within A Macro? Describe.

Answer»

Yes, Such MACROS are called nested macros. They can be OBTAINED by USING SYMGET and call symput macros.

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

11.

How Do You Add A Number To A Macro Variable?

Answer»

USING %EVAL FUNCTION or %sysevalf function if the NUMBER is a FLOATING number.

Using %eval function or %sysevalf function if the number is a floating number.

12.

What Is The Difference Between %put And Symbolgen?

Answer»

%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, in log window.

%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, in log window.

13.

What Do You Code To Create A Macro?

Answer»

We CREATE a MACRO with %MACRO STATEMENT and END a macro with %MEND STATEMNT.

We create a macro with %MACRO statement and end a macro with %MEND statemnt.

14.

If You Use A Symput In A Data Step, When And Where Can You Use The Macro Variable?

Answer»

The macro VARIABLE created by the CALL SYMPUT routine cannot be used in the same datastep in which it GOT created. Other than that we can USE the macro variable at any TIME.

The macro variable created by the CALL SYMPUT routine cannot be used in the same datastep in which it got created. Other than that we can use the macro variable at any time.

15.

How Long Can A Macro Variable Be? A Token?

Answer»
  • 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.

16.

How Can You Create A Macro Variable With In Data Step?

Answer»

With CALL SYMPUT.

With CALL SYMPUT.

17.

How Would You Invoke A Macro?

Answer»

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.

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.

18.

Have You Used Macros? For What Purpose You Have Used?

Answer»

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.

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.