@Hoibai wrote:
How can I pass an alphanumeric value with a dot (e.g., PST.2) to a macro? Thanks.
Dots (aka periods) do not normally cause any trouble for the macro processor.
The only place is when want to place a period immediately after the value of a macro variable reference. In your case if you wanted the value of PST to come from a macro variable named PREFIX you might try to use:
&prefix.2
But that will not work because the macro processor uses the period to mark the end of the macro variable name. In this case so that it knows the macro variable is named PREFIX and not PREFIX2. So to get the period into the value you need to include a second period.
&prefix..2
That character that does cause trouble with macro calls is the comma. That is because the macro processor uses comma to delimit the parameter values being passed. If you need to pass in a comma to a macro call you will need to mask it some how. One easy way is to design the macro to expect the value to have actual quotes around it.
%macro mymac(input,output,value);
data &output;
set &input;
name = &value ;
run;
%mend;
%mymac(sashelp.class,class,"Smith, Sam");
Note that the quotes are part of the value.
You could also use ( ) to mask the value, again the ( ) will be part of the value.
%macro mymac2(input,output,value);
data &output;
set &input;
where name in &value ;
run;
%mend;
%mymac2(class,class2,("Alfred","Smith, Sam"));
And finally you could use macro quoting.
%quote(Smith, Sam)
... View more