mac1c03 - 1 Chapter 3: Macro Definitions 3.1 Defining and...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 2 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 3 Objectives Define and call a simple macro. 3 4 Defining a Macro A macro or macro definition enables you to write macro programs. General form of a macro definition: macro-name follows SAS naming conventions. macro-text can include the following: 4 %MACRO macro-name ; macro-text %MEND < macro-name> ; %MACRO macro-name ; macro-text %MEND < macro-name> ; any text SAS statements or steps macro variable references macro statements, expressions, or calls any combination of the above 5 Macro Compilation When a macro definition is submitted, the following occur: Macro language statements, if any, are checked for syntax errors compiled. SAS statements and other text are not checked for syntax errors not compiled. The macro is stored as a SAS catalog entry in the temporary catalog work.sasmacr by default. 5 6 Macro Compilation The MCOMPILENOTE=ALL option issues a note to the SAS log after a macro definition has compiled. General form of the MCOMPILENOTE= option: The default setting is MCOMPILENOTE=NONE. 6 OPTIONS MCOMPILENOTE= ALL|NONE ; OPTIONS MCOMPILENOTE= ALL|NONE ; 7 Macro Compilation Example: Submit a macro definition. SAS Log 7 options mcompilenote=all; %macro time; %put The current time is %sysfunc (time(),timeampm.).; %mend time; m103d01 1 options mcompilenote=all; 2 %macro time; 3 %put The current time is %sysfunc 4 (time(),timeampm.).; 5 %mend time; NOTE: The macro TIME completed compilation without errors. 3 instructions 76 bytes. 8 Macro Storage Example: Produce a list of compiled macros stored in the default temporary catalog work.sasmacr . 8 proc catalog cat=work.sasmacr; contents; title "My Temporary Macros"; quit; My Temporary Macros Contents of Catalog WORK.SASMACR # Name Type Create Date Modified Date Description---------------------------------------------------------------- 1 TIME MACRO 11JUN2004:15:55:59 11JUN2004:15:55:59 PROC CATALOG Output m103d02 9 Calling a Macro A macro call causes the macro to execute is specified by placing a percent sign before the name of the macro can be made anywhere in a program (similar to a macro variable reference) represents a macro trigger is not a statement (no semicolon required). General form of a macro call: 9 %macro-name %macro-name 10 Calling a Macro Example: Call the TIME macro. SAS Log 10 %time 178 %time The current time is 2:49:39 PM. m103d01 11 11 12 3.01 Poll Does the macro call below require a semicolon?...
View Full Document

This note was uploaded on 02/20/2012 for the course STAT 506 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 90

mac1c03 - 1 Chapter 3: Macro Definitions 3.1 Defining and...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online