如何将 SAS 日期转换"30JUL2009"d
为YYYYMMDD
格式(例如 20090730)?
例如:
data _null_;
format test ?????;
test=today();
put test=;
run;
会在日志中给我“test=20090730”...
data _null_;
format test yymmddn8.;
test=today();
put test=;
run;
%let expectdate1=%sysfunc(putn(%eval(%sysfunc(today())-1),yymmddn8.));
您想使用格式 yymmddn8。'n' 表示没有分隔符。
根据http://support.sas.com/kb/24/610.html,您可以指定 B 为空白,C 为冒号,D 为破折号,N 为无分隔符,P 为句点,或 S 为斜线。
有这个也可以解决问题
%let today=%sysfunc(today(),yymmddn8.);
%put &today.;
以下链接中的所有内容
这是我在宏中的做法,但肯定有格式吗??!!!
%let today=%sysfunc(compress(%sysfunc(today(),yymmddd10.),'-'));
它很奇怪-INFORMAT yymmdd8。给出 YYYYMMDD 结果,而 FORMAT yymmdd8. 给出 YY-MM-DD 结果!!
当您在“索引”选项卡中输入“日期”,然后选择“日期和时间格式”时,您可以在“帮助”选项卡中查看所有日期和时间格式