Search code examples
postgresqlsascase

Understanding case statement in sas proc sql


I am having difficulty in understand this sas code.

select
      case    
       when DM_TURNOVER_TMP_STOCK."LIITM"n then   
        DM_TURNOVER_TMP_STOCK."LIITM"n     
      else   
        DM_TURNOVER_TMP_SALES."SDITM"n    
      end as "LIITM"n 
        
      case    
       when DM_TURNOVER_TMP_STOCK."LIMCU"n then   
        DM_TURNOVER_TMP_STOCK."LIMCU"n  

normally we use sas in sql in condition statment of column but here seems to be diffrent.Please help me in understanding this in postgres term.


Solution

  • Assuming this is a query from tables DM_TURNOVER_TMP_STOCK and DM_TURNOVER_TMP_SALES,
    when DM_TURNOVER_TMP_STOCK.LIITM is not missing and non zero, LIITM will get the value of DM_TURNOVER_TMP_STOCK.LIITM.
    Otherwise, it will get the value of DM_TURNOVER_TMP_SALES.SDITM.