【发布时间】:2010-11-15 11:31:09
【问题描述】:
如何将"30JUL2009"d 等SAS 日期转换为YYYYMMDD 格式(例如20090730)?
例如:
data _null_;
format test ?????;
test=today();
put test=;
run;
会在日志中给我“test=20090730”...
【问题讨论】:
如何将"30JUL2009"d 等SAS 日期转换为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 结果!!
【讨论】:
当您在“索引”选项卡中输入“日期”,然后选择“日期和时间格式”时,您可以在“帮助”选项卡中查看所有日期和时间格式
【讨论】: