everns
程序:
data b;
set a;
format x year4. ; /*x原为mmddyy10.格式,我想只输出年份*/
run;
打开数据集,该变量变成***,且log无错误提示。请教各位高手!
allen802
是不是格式year4.有误
everns
SASBASE书中有讲道这种格式啊
amitywei
很可能是你的数据集里的X变量并不是SAS日期值,自然就会出错了。
rtist
log无错误提示??也没有警告??
everns
没有警告
everns
刚看了一下,x的格式是datetime20.
amitywei
[quote]引用第6楼everns于2007-07-30 17:07发表的“”:
刚看了一下,x的格式是datetime20.[/quote]
这是SAS的日期时间值,和SAS的日期值不同。SAS的日期时间值是指某一天某一个时刻和1960年1月1日零时零点零分相差的秒数,而SAS日期值是指某一天和1960年1月1日相差的天数。所以两者的输出格式不能混淆。
如果楼主想求出年份的话求字符串吧,如myyear=substr(left(put(x,datetime20.)),6,4);
everns
谢谢amitywei!
这个数据集中的x我本来是定义成mmddyy10.的格式,整理好以后导出以excel保存,但是再用excel导入后,格式就变为了datatime20.
amitywei
用EXCEL导入的时候有选项可以控制按SAS日期型导入还是SAS日期时间型导入的,按照导入向导的步骤导入时有个"option",点击进去就可以看到那些选项。你试试吧!
hexm26
excel会自己改变数据的类型,尤其是日期和时间变量。这点非常恼火!所以你在重新读入excel数据时,一定要检查各个变量,有必要的话可以在excel里面直接改好了,再让SAS读。
rtist
[quote]引用第5楼everns于2007-07-30 04:01发表的“”:
没有警告[/quote]it doesn't make sense to me, as sas is a commercial product, which is supposed to think more for averaged-level users than the open R.
hexm26
[quote]引用第11楼rtist于2007-07-30 22:47发表的“”:
it doesn't make sense to me, as sas is a commercial product, which is supposed to think more for averaged-level users than the open R.[/quote]
haha, you expect SAS too much. As all of software I have used, SAS is the most user-unfriendly! Even so, SAS is still a very very powerful statistical package.
rtist
[quote]引用第12楼hexm26于2007-07-30 11:11发表的“”:
haha, you expect SAS too much. As all of software I have used, SAS is the most user-unfriendly! Even so, SAS is still a very very powerful statistical package.[/quote]
Giving a warning in such a case is probably the very basic-level consideration for any stat software. I can agree sas is very very big, but cannot agree it's very very powerful.
hexm26
[quote]引用第13楼rtist于2007-07-31 01:17发表的“”:
Giving a warning in such a case is probably the very basic-level consideration for any stat software. I can agree sas is very very big, but cannot agree it's very very powerful.[/quote]
It depends on how did you define "powerful".
everns
谢谢各位!
Statsfu
DATA A;
INPUT X MMDDYY10.;
DATALINES;
10-20-1999
;
RUN;
data b;
set a;
format x year4. ; /*x??mmddyy10.??,???????*/
run;
我这样是好的,
可能你从EXCEL导入数据的时候,需要选项用DATE.的形式,你没有CHECK,所以出现了那种格式
everns
数据集中有多个变量,导入sas中没有输入格式的提示