全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1672 5
2012-07-20
悬赏 100 个论坛币 已解决
was reading some sql code (may not be valid in sas proc sql):

cast((Date1+2 - Date2 month(4)) as int) - suppose date1 = 2011-07-15 and date2 = 2011-06-01, then what is the output?


googled a lit bit and looks like month(4) will be returning value of 1?

but if month(4) will returning value of 1, what does the left mean?

最佳答案

farmman60 查看完整内容

I try to answer your question, first of all, cast function belongs to SQL function, which convert an expression from one data type to another, not SAS function, so it could not be used in SAS, Both SQL and SAS have month function, normally we use month function as month(date), result will be month, for example, month('05Mar2012'd) will get 3, both in SAS and SQL. In SQL, month(0) will get 1, so I ...
二维码

扫码加我 拉你入群

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

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

全部回复
2012-7-20 06:27:59
I try to answer your question, first of all, cast function belongs to SQL function, which convert an expression from one data type to another, not SAS function, so it could not be used in SAS,  Both SQL and SAS have month function, normally we use month function as month(date), result will be month, for example, month('05Mar2012'd) will get 3, both in SAS and SQL. In SQL, month(0) will get 1, so I guess month(4) will get 5, however I am not familiar with SQL, I could not give you correct answer. Could you give me some forum money? Thank you.   
二维码

扫码加我 拉你入群

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

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

2012-7-20 12:21:54
好难的code.
二维码

扫码加我 拉你入群

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

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

2012-7-20 12:37:25

我们经常用的netezza SQL里面没有这种month  function, 而是用这个

date_part('month' , a.saledate) as month.

二维码

扫码加我 拉你入群

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

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

2012-7-20 15:24:55
能不能发更完整的code。没有上下文,很难理解吧
二维码

扫码加我 拉你入群

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

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

2012-7-21 03:46:38
the complete SQL code could be like the followings, but the problem is the SAS does not have a function called cast() yet, even in SAS v9.3, so it still can't make LZ's idea work, so what does the "cast((date1+2 - date2 month(4) as int)" mean? the word 'cast' means convert and it can convert int2char or char2int or something similar! and also month('03Apr2001'd)=4, but month(4)=1, even month(0)=1 in SAS, so cast((date1+2 - date2 month(4) as int) is not valid statement for proc SQL in SAS.
复制代码
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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