As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tips:Now You Can Use the IN Function in a Macro"

From sasCommunity
Jump to: navigation, search
m (added %LOWCASE)
m (wording modifications)
Line 4: Line 4:
 
options minoperator;
 
options minoperator;
 
%macro putme(name=)/mindelimiter=',';
 
%macro putme(name=)/mindelimiter=',';
%if %lowcase(&name) in alice,alfred,barbara %then
+
%if %lowcase(&name) in alice,alfred,barbara %then %put &name is in the list;
%put &name is in the list;
+
  %else %put name is NOT in the list;
%else %put Youre out of luck;
+
 
%mend;
 
%mend;
  
Line 13: Line 12:
  
 
</source>
 
</source>
Notice that we must specify the MINOPERATOR global option as well as the MINDELIMITER option within the macro definition.  The delimiter can be specified by the user.
+
The user must specify both the MINOPERATOR global option, the MINDELIMITER local option within the macro definition, and the delimiter for the MINDELIMETER option.
 
+
 
<!-- Insert any appropriate category tags - yu can have as many CATEGORY tag lines as you want.
 
<!-- Insert any appropriate category tags - yu can have as many CATEGORY tag lines as you want.
 
     it is important to put the category tags inside the <noinclude></noinclude> block so the categories are only applied to the tip page.
 
     it is important to put the category tags inside the <noinclude></noinclude> block so the categories are only applied to the tip page.

Revision as of 22:21, 2 May 2015

Starting in SAS 9.2, you can use the IN operator inside of a macro.

options minoperator;
%macro putme(name=)/mindelimiter=',';
	%if %lowcase(&name) in alice,alfred,barbara %then %put &name is in the list;
	   %else %put name is NOT in the list;
%mend;
 
%putme(name=Alice)
%putme(name=Buddy)

The user must specify both the MINOPERATOR global option, the MINDELIMITER local option within the macro definition, and the delimiter for the MINDELIMETER option.


....see also


Submitted By Mary Rosenbloom (talk)