In a macro I'm trying to write, I've got the macro working so that it makes a good WHERE clause that my Proc SQL code uses successfully. My question now is, if, in my parameter selection, I select a value of "none".... how do I translate that in my macro step so that my WHERE clause "goes away?". I want to be able to do this so if the user wants to see all values, the where clause gets blanked out. here is my macro code piece:
%let ethniccls = "%superq(ethnicity)";
%local i;
%if %superq(ethnicity0) ne
%then %do i=2 %to %superq(ethnicity0);
%let ethniccls = ðniccls,"%superq(ethnicity&i)";
%put ethniccls is ðniccls;
%put what you get when you reference ethniccls:;
%put (work.ethnic IN (ðniccls));
%end;
%if ethnicity eq "none" %then %do;
%let ethniccls = " ";
%end;
The code runs, but nothing results. I'm only trying to get ethniccls to be a blank value, but feel very dumb in my attempts.
%let ethniccls = "%superq(ethnicity)";
%local i;
%if %superq(ethnicity0) ne
%then %do i=2 %to %superq(ethnicity0);
%let ethniccls = ðniccls,"%superq(ethnicity&i)";
%put ethniccls is ðniccls;
%put what you get when you reference ethniccls:;
%put (work.ethnic IN (ðniccls));
%end;
%if ethnicity eq "none" %then %do;
%let ethniccls = " ";
%end;
The code runs, but nothing results. I'm only trying to get ethniccls to be a blank value, but feel very dumb in my attempts.