SAS Chapter 12: Storing Macro Programs

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,410
Questions: 10 | Attempts: 327

SettingsSettingsSettings
SAS Quizzes & Trivia

Practice for the SAS advance certification exam.


Questions and Answers
  • 1. 

    The %INCLUDE statement

    • A.

      Can be used to insert the contents of an external file into a program.

    • B.

      Will cause a macro definition that is stored in an external file to be compiled when the contents of that file are inserted into a program and submitted.

    • C.

      Can be specified with the SOURCE2 option in order to write the contents of the external file that is inserted into a program to the SAS log.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    The %INCLUDE statement can be used to insert the contents of an external file into a SAS program. If a macro definition is stored in an external file, the %INCLUDE statement causes the macro definition to be compiled when it is inserted into the SAS program. The contents of the macro definition will be written to the SAS log only if the SOURCE2 option is specified.

    Rate this question:

  • 2. 

    If you store a macro definition in a SAS catalog SOURCE entry

    • A.

      The macro definition can be submitted for compilation by using the FILENAME and %INCLUDE statements.

    • B.

      You can use the PROC CATALOG statement to compile the macro.

    • C.

      The SOURCE entry will be deleted at the end of the session.

    • D.

      You do not need to compile the macro before you invoke it in a program.

    Correct Answer
    A. The macro definition can be submitted for compilation by using the FILENAME and %INCLUDE statements.
    Explanation
    When a macro definition is stored as a catalog SOURCE entry, you must compile it before you can call it from a SAS program. You compile a macro that is stored as a catalog SOURCE entry by using the CATALOG access method. This creates a session-compiled macro that will be deleted at the end of the SAS session. The PROC CATALOG statement enables you to view a list of the contents of a SAS catalog.

    Rate this question:

  • 3. 

    Which of the following programs correctly sets the appropriate system options and calls the macro Prtlast? Assume that Prtlast is stored in an autocall library as a text file and that it has not been compiled during the current SAS session.

    • A.

      libname mylib 'c:\mylib'; filename macsrc 'mylib.macsrc'; options mautosource sasautos=(macsrc, sasautos); %prtlast

    • B.

      libname mylib 'c:\mylib'; filename macsrc catalog 'mylib.macsrc'; %prtlast

    • C.

      filename mylib 'c:\mylib'; options mautosource sasautos=(sasautos,mylib); %prtlast

    • D.

      libname mylib 'c:\mylib'; options mautosource sasautos=mylib; %prtlast

    Correct Answer
    C. filename mylib 'c:\mylib'; options mautosource sasautos=(sasautos,mylib); %prtlast
    Explanation
    To call a macro that is stored in an autocall library, you must specify both the MAUTOSOURCE system options and the SASAUTOS system option. The SASAUTOS system option can be set to include multiple pathnames or filerefs. Once these two system options are set, you can call the macro by preceding the macro name with a percent sign.

    Rate this question:

  • 4. 

    If you use the Stored Compiled Macro Facility,

    • A.

      The macro processor does not compile a macro every time it is used.

    • B.

      The only compiled macros that the Stored Compiled Macro Facility can access are those that are stored in the Sasmacr catalog.

    • C.

      You need to specify the MSTORED and SASMSTORE system options.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    The Stored Compiled Macro Facility enables you to store compiled macros permanently so that you can reuse them in later SAS sessions without compiling them again. Compiled macros must be stored in a catalog named Sasmacr, and both the MSTORED system option and the SASMSTORE system option must be specified.

    Rate this question:

  • 5. 

    Which of the following correctly creates a permanently stored compiled macro?

    • A.

      libname macrolib 'c:\mylib'; options sasmstore; %macro prtlast; / store proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;

    • B.

      libname macrolib 'c:\mylib'; options mstored sasmstore=macrolib; %macro prtlast / store; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;

    • C.

      libname macrolib 'c:\mylib'; options mstored sasmstore=macrolib; %macro prtlast; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;

    • D.

      libname macrolib 'c:\mylib'; %macro prtlast / store; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;

    Correct Answer
    B. libname macrolib 'c:\mylib'; options mstored sasmstore=macrolib; %macro prtlast / store; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;
    Explanation
    In order to create a permanently stored compiled macro, you must specify the MSTORED system option. The SASMSTORE system option must be specified to point to the library in which you want your macros to be stored. You must also use the STORE option in the %MACRO statement.

    Rate this question:

  • 6. 

    When you submit the following code, what happens? %macro prtlast; proc print data=&syslast (obs=5); title "Listing of &syslast data set"; run; %mend;

    • A.

      A session-compiled macro named Prtlast is stored in Work.Sasmacr.

    • B.

      A macro named Prtlast is stored in the autocall library. A macro named Prtlast is stored in the autocall library.

    • C.

      The Prtlast macro is stored as a stored compiled macro.

    • D.

      The Prtlast macro is stored as a SOURCE entry in a permanent SAS catalog.

    Correct Answer
    A. A session-compiled macro named Prtlast is stored in Work.Sasmacr.
    Explanation
    When you submit a macro definition, SAS creates a session-compiled macro and stores it in the temporary SAS catalog Work.Sasmacr. This macro will be deleted at the end of the SAS session.

    Rate this question:

  • 7. 

    Why would you want to store your macros in external files?

    • A.

      You could easily share your macros with others.

    • B.

      You could edit your macros with any text editor.

    • C.

      Your macros would be available for use in later SAS sessions.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    If you store your macro definitions in external files, you can easily share these files with others. Also, you can edit a macro definition that is stored in an external file with any text editor, and you can reuse the macro in other SAS sessions.

    Rate this question:

  • 8. 

    What will the following PROC CATALOG step do? proc catalog cat=mylib.sasmacr; contents; quit;

    • A.

      Copy the contents of the Sasmacr catalog to a temporary data set.

    • B.

      List the contents of the Sasmacr catalog as output.

    • C.

      Copy the contents of the output window to the Sasmacr catalog.

    • D.

      None of the above

    Correct Answer
    B. List the contents of the Sasmacr catalog as output.
    Explanation
    The PROC CATALOG step enables you to view a list of the contents of a SAS catalog. This might be especially useful if you store your macro definitions as SOURCE entries in permanent SAS catalogs. You might also use the PROC CATALOG step to see a list of the session-compiled macros that are stored in Work.Sasmacr.

    Rate this question:

  • 9. 

    Which of the following is not true about stored compiled macros?

    • A.

      Because these stored macros are compiled, you should save and maintain the source for the macro definitions in a different location.

    • B.

      The Stored Compiled Macro Facility compiles and saves compiled macros in a permanent catalog, in a library that you specify.

    • C.

      You do not need to specify any system options in order to use the Stored Compiled Macro Facility.

    • D.

      You cannot move a stored compiled macro to another operating system.

    Correct Answer
    C. You do not need to specify any system options in order to use the Stored Compiled Macro Facility.
    Explanation
    In order to use the Stored Compiled Macro Facility, you need to specify the MSTORED and SASMSTORE system options. The Stored Compiled Macro Facility saves the compiled macro in a permanent SAS catalog, but it does not save the macro definition. You cannot move a compiled macro across operating systems. Since you cannot re-create the macro definition from a compiled macro, it is a good idea to save your source program permanently as well.

    Rate this question:

  • 10. 

    Which of the following is not true?

    • A.

      The autocall macro facility stores compiled SAS macros in a collection of external files called an autocall library.

    • B.

      Autocall libraries can be concatenated together.

    • C.

      One disadvantage of the autocall facility is that the first time you call an autocall macro in a SAS session, the macro processor must use system resources to compile it.

    • D.

      The autocall facility can be used in conjunction with the Stored Compiled Macro Facility.

    Correct Answer
    A. The autocall macro facility stores compiled SAS macros in a collection of external files called an autocall library.
    Explanation
    The autocall macro facility stores macro definitions — not compiled macros — permanently. The first time an autocall macro is called during a SAS session, the macro is compiled and a session-compiled macro is created in Work.Sasmacr.You can have multiple autocall libraries that are concatenated, and you can use the autocall facility in conjunction with the Stored Compiled Macro Facility.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 15, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 25, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.