/******************* URBAN INSTITUTE MACRO LIBRARY *********************
: mparam_is_yes
Macro: Returns 1 if the macro parameter value is "Yes"
Description"y", "Y", "Yes", "YE", etc.)
(could be
: Function
Use
: Peter Tatian
Author
***********************************************************************/
mparam_is_yes(
%macro /** Macro parameter value to test (must resolve to a single value) **/
param
);
/*************************** USAGE NOTES *****************************
:
SAMPLE CALLmparam_is_yes( &quiet )
%*********************************************************************/
/*************************** UPDATE NOTES ****************************
*********************************************************************/
***** ***** ***** MACRO SET UP ***** ***** *****;
%
%local ;
***** ***** ***** ERROR CHECKS ***** ***** *****;
%
***** ***** ***** MACRO BODY ***** ***** *****;
%
%if %quote(%upcase((¶m))) = %quote((Y)) or
%quote(%upcase((¶m))) = %quote((YE)) or
%quote(%upcase((¶m))) = %quote((YES)) %then %do;
1
%end;%else %do;
0
%end;
***** ***** ***** CLEAN UP ***** ***** *****;
%
%mend mparam_is_yes;
/************************ UNCOMMENT TO TEST ***************************
= Y;
%let p %let result = %mparam_is_yes( &p );
=&p result=&result;
%put p
= Ye;
%let p %let result = %mparam_is_yes( &p );
=&p result=&result;
%put p= yEs;
%let p %let result = %mparam_is_yes( &p );
=&p result=&result;
%put p
= No;
%let p %let result = %mparam_is_yes( &p );
=&p result=&result;
%put p
= ;
%let p %let result = %mparam_is_yes( &p );
=&p result=&result;
%put p/**********************************************************************/
Check if Macro Parameter is Yes
Purpose: Returns 1 if the macro parameter value is “Yes” (could be “y”, “Y”, “Yes”, “YE”, etc.)