楼主: joe365
7313 10

[SAS] [求助]请教日期时间格式的问题,谢谢! [推广有奖]

  • 0关注
  • 0粉丝

初中生

33%

还不是VIP/贵宾

-

威望
0 级
论坛币
6 个
通用积分
5.4017
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
175 点
帖子
20
精华
0
在线时间
2 小时
注册时间
2007-10-9
最后登录
2010-1-12

楼主
joe365 发表于 2007-11-26 22:00:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
<span class="tpc_content">数据文件的日期时间格式是“2000-01-01 00:00:00”,不是SAS的标准格式,如何正常导入数据集呢?<br/>我现在的做法是把数据文件中日期时间这一栏分成两部分来处理,日期部分用yymmdd的格式,时间部分用time格式。不过,带来的问题是,生成数据集后,无法用来做时间序列分析,因为每一列的数据都有重复。<br/>请教各位,如何以正确的日期时间格式导入这种格式的数据?或者如何把生成的数据集中的日期和时间两列以datetime的格式合并为一列?<br/>谢谢各位!</span><br/>

[此贴子已经被作者于2007-11-26 22:00:54编辑过]

二维码

扫码加我 拉你入群

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

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

关键词:datetime 时间序列分析 time 数据文件 ATET 求助 请教 时间 格式

回帖推荐

aijinrong 发表于10楼  查看完整内容

you can use the following three steps:step1:    substr(variable,n1,n2) to get your year,month and day respectively,  and then apply ddmmmyy  formatstep2:    substr(variable,n1,n2) to get the rest parts  (       " 00:00:00)" then append the above two resultss  together, you will get character ,next you should transfer ...

aijinrong 发表于5楼  查看完整内容

per your request,  I think the very first step is to transfer character variable into numeric varible and rearrange sequence of your data ,  your will get the following new format ddmmmyy:hh:mm:ss.ssthen apply  datatimew.d  formatfor example :26NOV2007:03:32.21datatime21.2; 

本帖被以下文库推荐

沙发
sushe1527 发表于 2007-11-26 22:18:00
<p>这个问题,不会`</p><p>问下,在导入数据集前就对日期处理一下不就行了?excel里面的日期格式很多滴说~~比sas多</p>

藤椅
joe365 发表于 2007-11-26 22:24:00
<div class="quote"><b>以下是引用<i>sushe1527</i>在2007-11-26 22:18:00的发言:</b><br/><p>这个问题,不会`</p><p>问下,在导入数据集前就对日期处理一下不就行了?excel里面的日期格式很多滴说~~比sas多</p></div><p></p><p>多谢回复!</p><p>问题在于数据文件数量比较多,文件又比较大,如果依次处理会比较麻烦。不知道用其他软件比如Excel有没有批处理的方法?也许宏是个办法?不过,不太会用。</p><p>还是请教各位了。</p><p></p>

[此贴子已经被作者于2007-11-26 22:25:45编辑过]

板凳
sushe1527 发表于 2007-11-26 22:45:00
<p>明白了,那要是只是处理日期就好办了,提取excel那一列数据,放到excel里面,只处理一个,然后用右键拖不就可以了?然后用下数据merge不就好了,这样可以不?我q:276569191,在线聊吧,我新生</p>

报纸
aijinrong 发表于 2007-11-27 03:39:00
<p>per your request,&nbsp; I think the very first step is to transfer character variable&nbsp;into numeric varible and rearrange sequence of your data ,&nbsp; your will get the following new format&nbsp;</p><p><font color="#d56f2b">ddmmmyy</font>:hh:mm:ss.ss</p><p>then apply&nbsp; datatimew.d &nbsp;format</p><p>for example :</p><p>26NOV2007:03:32.21</p><p>datatime21.2;</p><p>&nbsp; </p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 10 精彩帖子

总评分: 经验 + 3  论坛币 + 10   查看全部评分

混在波士顿

地板
因扎齐 发表于 2007-11-27 04:01:00
<span class="tpc_content">时间序列分析需要怎样的日期类型?你有了时间,只不过天和小时是分开的罢了,把两个加起来不就得了吗?<br/>DATE是按天数存储的,TIME就不清楚了。<br/></span>

7楼
joe365 发表于 2007-11-27 10:44:00
<div class="quote"><b>以下是引用<i>sushe1527</i>在2007-11-26 22:45:00的发言:</b><br/><p>明白了,那要是只是处理日期就好办了,提取excel那一列数据,放到excel里面,只处理一个,然后用右键拖不就可以了?然后用下数据merge不就好了,这样可以不?我q:276569191,在线聊吧,我新生</p></div><p></p>&nbsp;<p>谢谢您的这个思路 </p><p>不过,最后还是需要把日期和时间合并为一列来处理。 </p><p>以SAS自带的时间序列预测工具为例,需要序列的time ID,datetime格式的比较合适,当然也可以用1,2……n这样的数列替代。但是,对于日期时间格式的转换的问题还是应该解决为好。</p>

8楼
joe365 发表于 2007-11-27 10:56:00
<div class="quote"><b>以下是引用<i>aijinrong</i>在2007-11-27 3:39:00的发言:</b><br/><p>per your request,&nbsp; I think the very first step is to transfer character variable&nbsp;into numeric varible and rearrange sequence of your data ,&nbsp; your will get the following new format&nbsp;</p><p><font color="#d56f2b">ddmmmyy</font>:hh:mm:ss.ss</p><p>then apply&nbsp; datatimew.d &nbsp;format</p><p>for example :</p><p>26NOV2007:03:32.21</p><p>datatime21.2;</p><p>&nbsp; </p></div><p></p><p>能否请您把字符型转换成数据型的过程说得详细一些呢?比如“2000-01-01 00:00:00”这种格式的数据,首先按照charw.的格式读入,然后如何转换成datetimew.d的格式呢?</p><p>直接用下面的语句不行,会提示错误。</p><p>informat&nbsp;data $CHAR20.;<br/>format&nbsp;data DATETIME20.;</p><p>初学SAS,烦请<em><strong>aijinrong</strong></em>指教一下。谢谢!</p>

9楼
joe365 发表于 2007-11-27 11:00:00
<div class="quote"><b>以下是引用<i>因扎齐</i>在2007-11-27 4:01:00的发言:</b><br/><span class="tpc_content">时间序列分析需要怎样的日期类型?你有了时间,只不过天和小时是分开的罢了,把两个加起来不就得了吗?<br/>DATE是按天数存储的,TIME就不清楚了。<br/></span></div><p>谢谢您的回复。</p><p>如何把分开的日期和时间合并为datetime格式的一列数据呢?因扎齐兄所说的把两个加起来,是如何操作的?能否详细说一下?谢谢!</p>

10楼
aijinrong 发表于 2007-11-28 06:35:00
<p>you can use the following three steps:</p><p>step1: &nbsp;&nbsp; substr(variable,n1,n2) to get your year,month and day respectively,&nbsp; and then apply ddmmmyy&nbsp; format</p><p>step2:&nbsp;&nbsp;&nbsp; substr(variable,n1,n2) to get the rest parts&nbsp; (&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" 00:00:00)" </p><p>then append the above two resultss &nbsp;together, you will get character ,</p><p>next you should transfer character&nbsp; into&nbsp; numeric</p><p>&nbsp;step3:&nbsp; apply datatimew.d &nbsp;format to your get your result,</p><p></p><p>In my options ,this method should be ok, I use this method in my clinical trials .hopefullly,you will get your results.</p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 10 精彩帖子

总评分: 经验 + 3  论坛币 + 10   查看全部评分

混在波士顿

您需要登录后才可以回帖 登录 | 我要注册

客服
GMT+8, 2026-12-5 03:24