|
|
板凳

楼主 |
发表于 2009-8-13 10:28:44
|
只看该作者
Re: 请教宏中日期的比较
[code:3q645c7n]%macro a(endd);
%let endd=%sysfunc(inputn(&endd,date9.));
%let char=%sysfunc(inputn(10AUG2009,date9.));
%if &endd<&char %then %do;
%put %sysfunc(putn(&endd,date9.));
%end;
%else %do;
%put %sysfunc(putn(&char,date9.));
%end;
%mend;
%a(31JUL2009);[/code:3q645c7n]
SAS宏变量的值永远是以character形式存储的,不管赋的是字符还是数值,宏变量"&endd"d解析后是字符串“31JUL2009”d
虽然在%if语句中会对expression自动调用%eval(),但字符串“31JUL2009”d没有被自动转换为numeric,仍然是character的,需要类型转换 |
|