16

如何将 SAS 日期转换"30JUL2009"dYYYYMMDD格式(例如 20090730)?

例如:

data _null_;
  format test ?????;
  test=today();
  put test=;
run;

会在日志中给我“test=20090730”...

4

5 回答 5

25
data _null_;
    format test yymmddn8.;
    test=today();
    put test=;
run;

YYMMDDxw。文件

于 2009-07-30T15:54:14.360 回答
13
%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 为斜线。

于 2009-08-07T19:41:39.963 回答
3

有这个也可以解决问题

%let today=%sysfunc(today(),yymmddn8.);
%put &today.;

以下链接中的所有内容

https://communities.sas.com/thread/60111

于 2014-08-05T10:22:44.943 回答
2

这是我在宏中的做法,但肯定有格式吗??!!!

%let today=%sysfunc(compress(%sysfunc(today(),yymmddd10.),'-'));

它很奇怪-INFORMAT yymmdd8。给出 YYYYMMDD 结果,而 FORMAT yymmdd8. 给出 YY-MM-DD 结果!!

于 2009-07-30T14:57:55.067 回答
0

当您在“索引”选项卡中输入“日期”,然后选择“日期和时间格式”时,您可以在“帮助”选项卡中查看所有日期和时间格式

于 2013-11-11T11:29:06.410 回答