SAS 中的 Oracle NVL 等效项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24186204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle NVL equivalent in SAS
提问by user3489870
I need to convert the sql code to sas code;
我需要将sql代码转换为sas代码;
NVL(SPRTELE_STATUS_IND, 'A') = 'A'
AND NVL(SPRTELE_PRIMARY_IND, 'Y') = 'Y'
AND NVL(SPRTELE_SEQNO, 99) =
(SELECT NVL(MAX(SPRTELE_SEQNO), 99)
FROM SATURN.SPRTELE D
WHERE SPRIDEN_PIDM = D.SPRTELE_PIDM
AND D.SPRTELE_TELE_CODE = 'MA'
AND NVL(D.SPRTELE_STATUS_IND, 'A') = 'A'
AND NVL(D.SPRTELE_PRIMARY_IND, 'Y') = 'Y'))
How can I convert NVL to sas? what is that mean
如何将 NVL 转换为 sas?那什么意识
回答by Gordon Linoff
The correct function to use instead of NVL()
is COALESCE()
. This is the ANSI standard function and supported by SAS, Oracle, and most other databases:
使用代替的正确函数NVL()
是COALESCE()
。这是 ANSI 标准函数,受 SAS、Oracle 和大多数其他数据库支持:
COALESCE(SPRTELE_STATUS_IND, 'A') = 'A'
AND COALESCE(SPRTELE_PRIMARY_IND, 'Y') = 'Y'
AND COALESCE(SPRTELE_SEQNO, 99) =
(SELECT COALESCE(MAX(SPRTELE_SEQNO), 99)
FROM SATURN.SPRTELE D
WHERE SPRIDEN_PIDM = D.SPRTELE_PIDM
AND D.SPRTELE_TELE_CODE = 'MA'
AND COALESCE(D.SPRTELE_STATUS_IND, 'A') = 'A'
AND COALESCE(D.SPRTELE_PRIMARY_IND, 'Y') = 'Y'))
There may be other differences in the full query.
完整查询中可能存在其他差异。
回答by Joe
NVL
in Oracle is equivalent to coalesce
in SAS. It says to pick the first nonmissing value from a list; so if you have NVL(A,B,C,0)
for example, if A is missing and B is missing and C is missing it will return 0; if one of them is non missing, it will return the earliest one that is nonmissing.
NVL
在 Oracle 中相当于coalesce
在 SAS 中。它说从列表中选择第一个非缺失值;因此,如果您有NVL(A,B,C,0)
例如,如果 A 缺失且 B 缺失且 C 缺失,它将返回 0;如果其中一个没有丢失,它将返回最早的一个没有丢失的。