SAS日期从文本转换。 [英] SAS date conversion from text.
问题描述
我导入了一个有以下日期的excel文件。
2012-01-09
2011-01-31
2010-06-28
2005-06-10
2012-09-19
2012- 09-19
2007-06-12
2012-09-20
2004-11-01
2007-03-27
2008-06-23
2006-04-20
2012-09-20
2010-07-14
导入后的日期已更改如下
40917
40574
40357
38513
41171
41171
39245
41172
38292
39168
39622
38827
41172
40373
我已经使用输入函数来转换日期,但它给出了一个奇怪的结果。
我使用的代码,
want_date = input(have_date,anydtdte12。
informat want_date date9;格式为has_date date9。; run;
我很喜欢这个世界的日期,任何想法如何转换这些?
您可以鼓励SAS在导入期间将数据转换为日期,尽管这不一定是灵丹妙药。
proc import file = whatever out = whatever dbms = excel replace;
dbdsopts =(dbSasType =(datevar = date));
运行;
其中 datevar
是您的日期列名称。这告诉SAS希望这是一个日期并尝试转换它。
请参阅所以你的数据在Excel 有更多的信息,或文档。
Hi I have a date conversion problem in SAS, I imported an excel file which has the following dates.,
2012-01-09
2011-01-31
2010-06-28
2005-06-10
2012-09-19
2012-09-19
2007-06-12
2012-09-20
2004-11-01
2007-03-27
2008-06-23
2006-04-20
2012-09-20
2010-07-14
after I imported the dates have changed like this
40917
40574
40357
38513
41171
41171
39245
41172
38292
39168
39622
38827
41172
40373
I have used the input function to convert the dates but it gives a strange result., the code I used.,
want_date=input(have_date, anydtdte12.);
informat want_date date9.; format have_date date9.;run;
I get very stange and out of the World dates., any idea how can I convert these?
You can encourage SAS to convert the data as date during the import, although this isn't necessarily a panacea.
proc import file=whatever out=whatever dbms=excel replace;
dbdsopts=(dbSasType=( datevar=date ) );
run;
where datevar
is your date column name. This tells SAS to expect this to be a date and to try to convert it.
See So Your Data Are in Excel for more information, or the documentation.
这篇关于SAS日期从文本转换。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!