Published on :
Macro CREATION_INTERNE

Using the IN operator and MINDELIMITER in SAS macros

This code is also available in: Deutsch Español Français
This script illustrates how to use the system option `minoperator` in conjunction with the macro option `mindelimiter` to check if a value belongs to a comma-separated list in an `%if` statement.
Data Analysis

Type : CREATION_INTERNE


No external data is used. Processing is purely logical at the macro level.

1 Code Block
MACRO
Explanation :
Enabling the `minoperator` option to allow the use of `IN` in macros. Definition of the `putme` macro using `mindelimiter=','` to accept a comma-separated list of values in the `%if` condition.
Copied!
1options minoperator;
2%macro putme(name=) / mindelimiter=',';
3 %IF %lowcase(&name) in alice,alfred,barbara %THEN %put &name is in the list;
4 %ELSE %put name is NOT in the list;
5%mend;
2 Code Block
MACRO CALL
Explanation :
Execution of the macro with two test values: 'Alice' (which is in the list) and 'Buddy' (which is not).
Copied!
1%putme(name=Alice)
2%putme(name=Buddy)
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.