SAS 格式 DATE9。至 DDMMYYd10。在 select 声明中

SAS Format DATE9. to DDMMYYd10. in select statement

如何格式化 DATE9.日期为 DDMMYYd10。在我的 select 声明中?

PROC SQL;
 CREATE TABLE TEST AS
 SELECT BIRTH_DT
 FROM CUSTOMER
QUIT;

我试过了:

PROC SQL;
 CREATE TABLE TEST AS
 SELECT BIRTH_DT FORMAT=DDMMYYd10.
 FROM CUSTOMER
QUIT; 

也尝试过:

PROC SQL;
 CREATE TABLE TEST AS
 SELECT DATEPART(BIRTH_DT) FORMAT=DDMMYYd10. AS BIRTH_DT
 FROM CUSTOMER
QUIT; 

但这会引发错误。

当前输出是 28MAY1960,我需要 28-05-1960

您收到错误消息是因为在 from 语句后缺少 semi-colon ;。也不需要 datepart 函数。

data have;
  dt_birth = '28MAY1960'd;
  format dt_birth date9.;
run;

proc sql;
    create table want as
    select dt_birth format=ddmmyyd10.
    from have;
quit;
28-05-1960