SAS中文论坛

标题: 关于title statement 中含有特殊符号(& % ...)的一个问题 [打印本页]

作者: shiyiming    时间: 2012-5-25 06:20
标题: 关于title statement 中含有特殊符号(& % ...)的一个问题
%macro a(title=);
proc print data=sashelp.class;
%if &title.>'' %then %do;
title "%upcase(&title.)";
%end;
%else %do;
  title "default title";
%end;
run;
%mend;

%a(title=abc %^&)
这个code是为了加个title(要求upcase),但如果参数title=''为空时,则用‘default title’.
问题:一旦加入特殊符号,比如& % 等,就无法运行,请高手指点一下。对于 " ' "(single quation mark,i.e. title=Mike's laptop),能解决最好,不能解决就不要考虑。

thanks a  lot.
作者: shiyiming    时间: 2012-5-26 00:31
标题: Re: 关于title statement 中含有特殊符号(& % ...)的一个问题
用函数%nrstr()

[code:l14kvvnc]
%macro a(title=);
proc print data=sashelp.class;
%if &title.>'' %then %do;
title "%upcase(&title.)";
%end;
%else %do;
title "default title";
%end;
run;
%mend;

%a(title=%nrstr(abc %^&))

[/code:l14kvvnc]




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2