Section 2.8 - Comments To document a SAS program -- use comments! The addition of comments into a list of SAS statements greatly helps you keep track of what is done. They are especially useful several days/weeks/months later when you return to a program and want to quickly determine what was done. They are also helpful when you want to omit a statement of block of statements from a particular run; SAS has at least three ways to enter comments into a program: 1. All text that begins with an asterisk * (i.e., an * that follows the most recent semi-colon) will be treated as a comment up to the next semi-colon. This option is most useful for entering a small number of single-line comments to document the next block of statements or to skip a SAS statement without deleting it from the block. A few illustrations: * enter a single-line comment; * a comment continues until the next semicolon even across more than one line; * Remove one statement by entering an asterisk at the beginning (i.e., before the keyword) of that statement; PROC GLM DATA=xyz; CLASS a b; MODEL y = a b a*b / solution; * MEANS a / lsd; * The MEANS statement is not applied here ; RANDOM b a*b; RUN; 2. All characters or SAS statements that fall between /* */ are ignored. This comment procedure is most useful for omitting blocks of statements or when writing long documentation within the program. For example, to eliminate a block of statements (such as code for one or more SAS procedures) from running, enclose the entire block within /* */ as shown below: /* PROC GLM DATA=xyz; CLASS a b; MODEL y = a b a*b c c*a c*b / solution; MEANS a / lsd; RANDOM b a*b; RUN; */ One very convenient feature of /* */ is that you can deactivate portions of individual SAS statements. For example, when running a fixed effects ANOVA with PROC MIXED, to eliminate the interactions and estimate a main-effects-only model, enclose the interaction terms with /* */. PROC MIXED; CLASS a b; MODEL y = a b /* a*b */ c /* c*a c*b */ / solution; The preceding PROC step applies the MODEL statement as if it were written: MODEL y = a b c / solution; Comments made with /* */ cannot be nested (i.e., commenting blocks that already contain sections of this type of comment is not allowed). For example, entering the following step will produce an error message in the log file: /* PROC MIXED; CLASS a b; MODEL y = a b /* a*b */ c /* c*a c*b */ / solution; */ 3. Treat blocks of SAS statements as a macro which is never used: %MACRO tmp; < all code to be treated as comments > %MEND tmp; Note: SAS macros are a programming tool very much like subroutines; that are often used to save time when invoking the same analysis steps multiple times (See Chapter 9).