数学之路-sas备忘(16)

本文详细介绍了SAS中处理日期和时间的格式,包括DATETIMEw. informat的使用,例如2013.03.07、17:25:38等格式的转换和显示方式,并提供了示例代码展示如何获取和格式化当前日期时间。
摘要由CSDN通过智能技术生成

SAS日期及时间格式

data _null_;
mydate ='7MAR13'd;
put mydate YYMMDDP10.;
put mydate YYMMDDN8.;
put mydate YYMMDDC10.;
put mydate YYMMDDS10.;
put mydate YYMMDD10.;
put mydate WEEKDATE.;
put mydate WORDDATE.;
run;


本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/


2013.03.07
20130307
2013:03:07
2013/03/07
2013-03-07
      Thursday, March 7, 2013
     March 7, 2013
NOTE: “DATA 语句”所用时间(总处理时间):
      实际时间          0.01 秒
      CPU 时间          0.01 秒

==============

data _null_;
mytime ='17:25:38't;
put mytime HHMM.;
put mytime TIME.;
put mytime TIMEAMPM.;
put mytime HOUR.;
put mytime TOD.;
run;





17:26
17:25:38
 5:25:38 PM
17
17:25:38


data _null_;
now=datetime();
put now DATEAMPM.;
put now DATETIME.;
put now nldatm.;
run;


30MAR15:03:12:14 PM
30MAR15:15:12:14
2015年03月30日 15时12分14秒



data _null_;
now=date();
put now YEAR.;
put now MONTH.;
put now DAY.;
run;

2015
 3
30
NOTE: “DATA 语句”所用时间(总处理时间):
      实际时间          0.00 秒
      CPU 时间          0.00 秒


data _null_;
/*当前日期及时间*/
now=date();
put now YEAR.;
put now MONTH.;
put now DAY.;
put now=nldate.;
t1=time();
put t1=time.;
put t1=nltimap15.;
d1=today();
put d1=nldate.;
d2=today();
put d2=nldate.;


run;


2015
 3
30
now=2015年03月30日
t1=15:21:50
t1=下午03:21:50
d1=2015年03月30日
d2=2015年03月30日
NOTE: “DATA 语句”所用时间(总处理时间):
      实际时间          0.01 秒
      CPU 时间          0.01 秒


Writes datetime values in the form ddmmmyy:hh:mm:ss.ss.

Category: Date and Time
Alignment: Right
Restriction: If wd< 17, SAS truncates the decimal values.
Interaction: When the DECIMALCONV= system option is set to STDIEEE, the output that is written using this format might differ slightly from previous releases. For more information, see DECIMALCONV= System Option in SAS System Options: Reference.

Syntax

DATETIMEw.d

Syntax Description

w

specifies the width of the output field.

Default 16
Range 7–40
Tip SAS requires a minimum w value of 16 to write a SAS datetime value with the date, hour, and seconds. Add an additional two places to w and a value to d to return values with optional decimal fractions of seconds.
d
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值