The comma is used as a separator for macro parameters.
You need to tell SAS that these commas are part of the parameter value and are not separators.
This is done thus:
%first(dsn=mydata, bylist=%str(x, y, z) , outdat=outfile);
Alternatively, if you don't want to burden the users of the macro, add the commas inside the macro (replace intermediate spaces with commas).
%first(dsn=mydata, bylist=x y z , outdat=outfile);
select %sysfunc(translate(%str(&bylist), %str(,), %str( ) ) )
... View more