sas 信息日期时间
任何人都可以建议适当的 SAS 信息来读取日期时间 (dd/mm/yyyy hh:mm) ???
例如
data _null_;
informat from_dt datetime????.;
input from_dt ;
put from_dt=;
cards;
01/01/1960 00:00
;run;
Can anyone advise on the appropriate SAS informat to read in a datetime (dd/mm/yyyy hh:mm) ???
eg
data _null_;
informat from_dt datetime????.;
input from_dt ;
put from_dt=;
cards;
01/01/1960 00:00
;run;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
通常,anydt* 系列信息确实有效。
The anydt* family of informats do work, usually.
我不认为特定的信息是内置的,但推出自己的信息相对容易。下面是创建自定义日期时间信息(这需要 cntlin 数据集)和自定义格式(使用图片语句)的示例,该格式读取您的特定日期时间,然后将其格式化以使其看起来与输入相同。我通过假设时间部分始终为午夜 (00:00) 来简化它,但如果您还需要跟踪时间部分,则可以轻松扩展它(只需将 86400 数字更改为 3600 即可获取每小时,并且 60每分钟)。如果您打开 work.infmt 数据集以查看其外观,将有助于了解正在发生的情况。
这给出了这样的输出:
I don't think that specific informat is built-in, but it is relatively easy to roll your own. Below is an example of a creating a custom datetime informat (this requires a cntlin data set) and a custom format (using the picture statement) that reads in your specific datetime and then formats it back out to look the same as the input. I simplified it by assuming the time part was always midnight (00:00), but it can be easily expanded if you need to keep track of the time parts as well (just change the 86400 number to 3600 to get every hour, and 60 for every minute). It helps to see what is going on if you open the work.infmt data set to see what it looks like.
This gave an output like this:
SAS 可能不支持数据所在的特定日期时间格式。您可以尝试将传入数据转换为更友好的格式,也可以使用 substr, DHMS 和 MDY 函数:
或者您可以将日期时间字符串转换为 datetimew.d 格式并输入格式化字符串
:转换可以压缩为单个但复杂的语句,因此为此创建一个宏可能是一个不错的决定。
SAS might not support the specific datetime format your data is in. You could either try to convert the incoming data to a frendlier format or you could parse the datetime using the substr, DHMS and MDY functions:
Or alternatively you could convert the datetime string into a datetimew.d format and input the formatted string:
The conversion can be compressed to a single but complex statement, so creating a macro for this might be a good decision.
此条目来自 SAS 知识库 包含用于解析和格式化日期时间的代码。看起来 SAS 有一个很棒的在线帮助系统。
Google 网上论坛的交流中的第三条消息可能也会有帮助。它讨论了输入日期时间,并提供了代码。
你的问题很难理解,而且我对 SAS 知之甚少,我只能提供这么多。希望有帮助。
This entry from the SAS knowledgebase includes code for parsing and formatting datetime. Looks like SAS has a great online help system.
The third message in this exchange on Google groups may be helpful as well. It talks about inputting datetime, and provides code.
Your question is so hard to decipher, and I know so little about SAS, that's about all I can offer. Hope it helps.
按照此处的列表,我认为没有。
可以想象,您可以使用
proc 格式
创建自己的格式,但我认为这会非常困难。 Ville Koskinen 的建议可能是您最好的选择。Going by the list here, I don't think there is one.
Conceivably you could create your own with
proc format
, but I think that would be very difficult. Ville Koskinen's suggestion is probably your best bet.