Option symbolgen mprint mlogic arero950516026
4 stars based on
This post will focus on macro programs. You can read one of my previous posts to see the details about SAS macro varlables. Here is the syntax for sas programs. Arguments enclosed in angle brackets are optional. Therefore, parameter-list and option are not reuired when building sas macros. Though parameter-list is optional, it is very important if you want to pass values to macro program.
It is macro parameters which can enable you to do different though similar work such to run macro program on different data without changing macro program. Fundamentally, macro parameters will be treated as macro variable in macro program. As we all know that, the most important feature of macro program is to do repeatitive work.
Before starting to think how to develop macro, we have to create code which can at least do one of those repeatitve work. Code in below figure can get statistics such mean, std, min, max and median for female students at each of ages 11, 12, 13, 14 and Suppose that we give this macro a name — dist and give options symbolgen mprint mlogic macro two parameters: So far, a macro program named dist have been built successfully.
We can execute a macro program by sumitting a reference to the macro program. If the macro have options symbolgen mprint mlogic, we still have to include parameter list when executing macro program. In below figure, we call macro dist four times.
If you submit below code, you will find that you can get 4 different datasets having the same name dist. Each of them contains summary statistics for students meeting criteria listed in parameter list. In another word, you will get summary statistics of height for female students. The left part options symbolgen mprint mlogic below figure shows you how to build macro using positional parameters and how to call the macro. This approach is error-prone, right?
The right panel in below figure shows you how to create macro using keyword parameter. We can also use a mix of positonal parameter and keyword parameter to develop macro programs. Since positional parameter is error-prone and I strongly recommend you to use keyword paramter options symbolgen mprint mlogic in daily programming life.
And thus how to create macro using a mix of positional parameter and keyword parameter will not be described here. There are three values available for mcompilenote option: NONE can suppress display of all macro program compilation notes.
When you set mcompilenote to be all and place the statement before you macro program, you will get the compile note successful or not in the log. If you want to see the sas code that macro processor constructs and submits, you have to enable mprint option. Those are not enclosed in squares are the code constructed and summitted by macro processor.
With the help of these options, you can debug your macro programs easily. And you can disable these options using nosymbolgennomprintnomlogic. The macro variables that options symbolgen mprint mlogic be referenced are stored in macro symbol tables.
There are two types of macro symbol tables: Macro variables stored in global symbol table are global macro variables while those stored in local symbol table are local macro variables. You can reference global macro variables throughout your SAS session from both open code and within macro programs.
However, local macro variables can only be resolved from within the options symbolgen mprint mlogic program that define them. Here shows you how to add macro variables to the global macro symbol table. One way is to create macro variables in open code.
As I described previously, macro variables defined within a macro program will be local macro variables. Here is an example which can make good demonstration of differences between local macro variable and global macro variable. From below figure, you can see that there are two macro variables named age. Welcome to share or you can subscribe to get latest post. Go to the top-right corner of this web page to submit your name and email address.
Your email address will not be options symbolgen mprint mlogic. Tagged as automatic macro variable global macro options symbolgen mprint mlogic key parameter local macro variable macro parameter mcompilenote mlogic mprint positional parameter symbolgen. Leave a Reply Cancel reply Your email address will not be published.