| |||||
Edit ToolsSome of the following macros have been set up to run through the use of templates. Most are available from the context sensitive menus and tool bars. Any of these macros can be invoked while using a file without a SAS extension. To run the macros from a non-SAS file select and type SAS^macroname, in the macro name field. Single line commentsSelect the text to be turned into a comment. Use menu item or select off of the submenu of the context sensitive (right click) menu, You should not use this method to "comment out" a large block of code by selecting the whole block. Use the menu item off the submenu of the context sensitive menu. The method can also be used to uncomment a block of code that you "commented out" using that method. Note in the example below how the comments contained in the block to be "commented out" are altered so that they do not interfere with the larger block comment Single line with Comment Block Commands-Comment line selected text:Before:data temp2;
set temp;
if x > 11;
run; this is a comment
After:data temp2; set temp; if x > 11; run; /* this is a comment*/ Block of lines with Comment Block Commands-Comment Uncomment:You can comment out a block of code by selecting it with the mouse, and invoke the Comment Un comment menu item from the Comment Block Commands selection of the context sensitive menu. This function can also be invoked by pressing the Com Out button from the SAS toolbar. Any comments within the block of code are altered to prevent them from effecting the commented out block. This conversion is easily removed by using the same function on that block of code again. If you have previously used this function on a block of code, you can remove the comment blocking. The comments will be removed and any contained comments will be returned to their original form. Conversion of a Block of lines with Comment Un comment: data temp2; set temp; if x > 11; /* this is important */ run; After: /***# Comment Out Start **************************
data temp2;
set temp;
if x > 11; \* this is important *\
run;
**************************** Comment Out End #***/
Single Line Block CommentsYou can create a small comment box around a single line with the comment block single line edit macro. You can invoke this macro through the selection off the submenu of the (right click) context sensitive menu. Or you can use template expansion, pressing the button on the SAS toolbar, or by running the macro cbline (SAS^cbline from a non *.sas file). When used through the context sensitive menu or the Macro-Run menu the cursor must be on the line containing the comment. When using template expansion just type cbl followed by a space at the end of the line. The first character on the current line determines where the comment symbol begins if that character is in column 1 through 4. If the first character is beyond column 4, then the comment's first "/" begins 3 positions to the left. This is done to prevent a "/" from occuring in column 1, which would cause problems if the SAS code is included in a JCL stream. A before and after example of the operation is shown below. Before:run;
Sort the new data!|
proc sort data=indata.mystuff;
by var1;
run;
After:run;
/**********************/
/* Sort the new data! */
/**********************/
proc sort data=indata.mystuff;
by var1;
run;
Block CommentsYou can create a comment box around a block of lines with the comment block edit macros. You can invoke these macros through the (right click) context sensitive menu with off the submenu. You can also press the button (or ) on the SAS toolbar. You can also use the template expansion (if you have persistent blocks set on), or by running the macro cbit (SAS^cbit from a non *.sas file), cbit2 or cbit3 . When used through the context sensitive menu or the menu you must have the comment lines selected as a block. All the comment block functions are listed in the sub menu of the context sensitive menu selection . When using template expansion just type cbk followed by a space (or cbk2, cbk3 ) at the end of the selected block. Note, you must have persistent blocks turned on ( menu) to use the template expansion method. The starting position (column) and length of the first line determine where the comment box starts and the total width of the box. The position of the subsequent line is not relevant. All the text in the selected block are word wrapped to fit into the comment box with a blank on the left margin and left justified. Note that all duplicate blanks are eliminated from the selected text before it is fit into the box. A before and after example of the operation is shown below. Before:run;
This is a very critical part
of my overly important program. (I feel that
the usefulness
of
the
program is highly under rated.)
proc sort data=indata.mystuff;
by var1;
run;
After:run;
/*************************/
/* This is a very */
/* critical part of my */
/* overly important */
/* program. (I feel that */
/* the usefulness of the */
/* program is highly */
/* under rated.) */
/*************************/
proc sort data=indata.mystuff;
by var1;
run;
You can create larger blocks by placing more blanks before the last word in the first sentence of the text to be comment blocked. Before:run;
This is a much larger comment block
but is still important
proc sort data=indata.mystuff;
by var1;
run;
After:run;
/**************************************************/
/* This is a much larger comment block but is */
/* still important */
/**************************************************/
proc sort data=indata.mystuff;
by var1;
run;
The other comment box macros cbit2 and cbit3 work the same as cbit except that the box is constructed using ** and *** respectively. Make MacroThe makemac macro creates a separate file and wraps the opening and closing code (%macro, %mend ) around the selected text in the current file. The macro prompts you for a name for the SAS macro. The macro's name is used to create the file name for the new file. The current file's path is used to determine where to place the new file. The extension ".sas" is used for the new file. A new edit window opens, containing the macro file. You can invoke this macro through the menu, or select in the submenu of the context sensitive menu, or by pressing the button on the SAS toolbar. If you had selected the following text and entered "flop" when prompted for a macro name.
proc sort data=indata.mystuff;
by var1;
run;
You would have the following in the file "flop.sas" created in the same directory as the file that contained the selected text. The file flop.sas is opened for editing%MACRO flop (`parms`) ; proc sort data=indata.mystuff; by var1; run; %MEND; /* flop */ Note the use of `parms` on the first line. You can use Cntl-i to jump to the field string ( `parms` ) with it selected (for over typing) just as you might do when expanding a template. Hiding Blocks of CodeWhen editing large files it is useful to be able to hide blocks of code. You can do this with the Block button on the SAS Tool bar or through the context sensitive menu under Tools-Hide Block. The operation of this function is similar to the exclude line command under ISPF edit. First you select the lines to be hidden with either a stream or line block. Then either select the function off of the context sensitive menu or press the Block button on the tool bar. To view the hidden block either press the On Off or button on the tool bar or select these options from the context sensitive menu. The Clear function removes all hide code marks from the file. The On Off function toggles between hidden and viewable for all hidden code in the file. You can also use the + button at the beginning (left side) of the hidden code to just expand that hidden block. When you press the + button the code is expanded and the + button changes to a - button. Pressing the - button will rehide the block. Tool BarsMany of the tools available through the context sensitive menus are also on tool bars. Below is a graphic description of the tool bars for SAS and LOG files. The buttons on these tool bars are in "large" format. If you alter the tool bars to display small buttons then you will not be able to read (identify) the buttons with text on their faces. Note the SAS and LOG tool bars are located at the bottom of the Multi-Edit window. SAS Tool Bar
Log Tool Bar
Copyright © 2000- , Martin Works Inc., Text, graphics, and HTML code are protected by US and International Copyright Laws, and may not be copied, reprinted, published, translated, hosted, or otherwise distributed by any means without explicit permission. SAS® is a registered trademark of SAS Institute, Inc. in Cary, NC. Multi-Edit® is a trademark of Multi-Edit Software Inc. All other logos and trademarks in this site are property of their respective owners. |