Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle NVL equivalent in SAS

Tags:

sql

oracle

sas

I need to convert the sql code to sas code;

  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

like image 454
user3489870 Avatar asked Feb 12 '23 18:02

user3489870


1 Answers

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:

  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.

like image 104
Gordon Linoff Avatar answered Feb 15 '23 09:02

Gordon Linoff