For example, i have a macro program
%macro test(parameter1= , parameter2=, parameter3=);
DATA data_gender;
SET data_input(WHERE=(gender=parameter3));
RUN;
.....
%mend;
Basically, i made a selection of observations using the parameter3 (Male or Female). Now i want to create a third option: to keep both observations in Male and Female when the parameter3 is empty (without declaring the value of this parameter).
%test(parameter1=xxx , parameter2=yyy, parameter3=);
Can you tell me how can i do that please?
Agree with Joe's answer. One good point they make in the paper is they are testing for blank, and their test will return true whether a parameter is null or has blanks in it. Sometimes it is useful have a test that differentiates between a parameter that is null and one that has blanks. The paper mentions
%length(%superq( ))
as a possible test for null. For example below, this allows you to specify a blank value for sex, and get a different result than you do when sex is null.For this answer I will cite Chang Chung's seminal paper, "Is This Macro Parameter Blank", as it is excellent and goes into great detail about your options here.
The "best" option follows (ie, using the recommended method from the paper above). Note the initial
%test
macro doesn't return any rows for the blank parameter, while the second%test2
does.There are simpler ways to test for a macro parameter being blank that work in most cases, and read the paper for more details about the simpler options.