全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
10241 5
2011-04-26
学sas 有段时间了。
但是,sas 的日期、数字、字符,三者之间的转换一直有点晕晕的。
看到例子程序明白,自己一写,就问题一堆。

哪位大侠,给指点下。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-4-26 22:18:35
SAS的日期时间都是数字型的,以便于计算。有各种格式可以从数值转变为字符型。1960-01-01是日期的开始,SAS的日期是0. 之后每天加一。1960-01-02的值为1. 1959-12-31的值为-1. 以此类推。时间是一秒为单位计算。从0(00:00:00)到86400(24:00:00)。每加一秒数值加一。
常用的日期时间转换的function如下:
data _null_;
a=mdy(12,31,1959);
b='02jan1960'd;
c='24:00:00't;
d='00:00:00't;
e='31dec90:5:00:00'dt;
format e datetime18.;
put a= b= c= d= e=;
run;
a=-1 b=1 c=86400 d=0 e=31DEC90:05:00:00
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-4-28 07:54:45
1# jiangh_fox


I give you some example in my real project :

The Character version of Date I`m usually encountered with looks like this "mm/dd/yyyy". What I want is to transfer this into Date9. format which could be esaily computed in SAS.

Define the Format first:

复制代码


Set up the utility macro like this :

复制代码



After that, you could easily call macro %dt within the rest of your program.

复制代码


The date transfer issue come acrossed a lot in the clinical trial projects. I hope the above contents are making sense to you.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-5-23 17:33:08
学习了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-15 10:14:02
好精辟
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-1-2 00:01:32
很好的分享
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群