Your main problem is that you need to let SAS know that you want to use in
as an operator in your macro logic.
To enable use of IN
as an operator in macro language then you need set the MINOPERATOR
option. To insure it always works for your macro independent of how the system option is set add it to the %macro
statement.
%macro Control1(List) / minoperator mindelimiter=' ';
But you also have a number of other issues.
When defining a parameter to the macro you just want to type the name you want to parameter to have. Your example has an &
before the name which would be invalid syntax and that is used to reference the value of macro variable and you cannot use the value to macro variable to name your parameter. So when defining the macro just list the name
%macro control1(list) .....
Note than when you CALL the macro is fine to reference a macro variable when passing in the parameter value to the macro, as you have done in your example call.
The %if
statement has multiple problems. The first appears to just be a typo with an extra e
added to the end of the list
macro variable's name. The second is a logical mistake. The value the macro variable CONTROL1
is never going to be the same as that value with double quote characters around it. Also the ()
around the list of values for the in
operator are not needed, but they won't cause any actual problems.
%if &control1 in &list %then %do;
Your SELECT statement is missing a comma between the two variables you are selecting.
select id,count(id) as number
The condition in your HAVING clause is not valid syntax. Are you trying to test if the count is larger than 1? Plus if you want to reference a variable you have calculated you need to use the CALCULATED keyword.
having calculated number > 1
Finally it is potentially confusing to reference two macro variables, CONTROL1 and PROUDUIT, in your macro that are not defined by the code (or even documented in a comment). They are not input parameters. You have not declared them as local macro variables. Or done anything to insure that they will exist.