The code is same Scott. I have just changed the macro variable name. If you want it that way only,then Check out this code::::::::::::::::::::::::::::::::::::
data test;
infile datalines dlm = '|' dsd;
input name :$50. 'rh id'n ;
datalines;
a|2
i|3
c|7
d|1
e|0
f|4
;
run;
%MACRO SORT(DS= , KEY = );
proc sort data =&DS;
by &KEY ;
run;
%MEND SORT(DS= , KEY = );
%SORT(DS = test,KEY = %str(%'RH ID%'n))
/*************************************************************/
And the log is as follow::::::::::::::::::::::::::::::::
/*************************************/
NOTE: The data set WORK.TEST has 6 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
Memory 292k
Page Faults 2
Page Reclaims 0
Page Swaps 0
Voluntary Context Switches 6
Involuntary Context Switches 1
Block Input Operations 0
Block Output Operations 0
24 ;
25 run;
26 %MACRO SORT(DS= , KEY = );
27 proc sort data =&DS;
28 by &KEY ;
29 run;
30 %MEND SORT(DS= , KEY = );
WARNING: Extraneous information on %MEND statement ignored for macro definition SORT.
31 %SORT(DS = test,KEY = %str(%'RH ID%'n))
ERROR: Variable N not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
Memory 20k
Page Faults 0
Page Reclaims 0
2 The SAS System 10:04 Wednesday, March 24, 2010
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
NOTE: Line generated by the macro variable "KEY".
31 'RH ID'n
_
22
__
202
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, DECENDING, DESCENDING, DESENDING, _ALL_, _CHARACTER_,
_CHAR_, _NUMERIC_.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
32
33 %LET _CLIENTTASKLABEL=;
34 %LET _EGTASKLABEL=;
35 %LET _CLIENTPROJECTNAME=;
36 %LET _SASPROGRAMFILE=;
37
38 ;*';*";*/;quit;run;
39 ODS _ALL_ CLOSE;
40
41
42 QUIT; RUN;
43
/****************************************************************/