Well, to answer your question;
options MPRINT MLOGIC MERROR SYMBOLGEN;
%macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
proc sort data = &dsn out = &s_dsn &key
%if &d_dsn. ne %then %do;
dupout = &d_dsn
%end
;
by &byvar;
run;
%mend;
%srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);
However to add, why would you want to create a standard sort macro? You are just obfuscating what is a simple base SAS procedure for no apparent reason. Let me explain, all SAS programmers know how to write a proc sort step, now along comes the macro varient which wraps up some code and hides it behind a %srt call. What does that mean, does it sort it ascending or descending, what about indexes, does it do anything else. You have taken something simple and well known and obfuscated it. Macro is not a replacement for Base SAS, and half the skill of creating an efficient standard macro library is knowing where to use macro and where not.
Also, please put the dot after macro variables, whilst not always necessary it is a good idea to always do it (and it will highlight in editor).
... View more