Looking for YTD Claim Spend

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Looking for YTD Claim Spend

Looking for members with over X$ claims in 2014

This query is pulling the members but is not filtering only to 2014, do I not have the date in the correct place?

proc sql;

     create table TOTAL_PAID as SELECT DISTINCT MBR_SYS_ID,

               SUM(SRC_PD_AMT) as TOTAL_CLAIMS FROM DB2.INS_CLAIM A

               WHERE A.CLM_PD_DT >= '01JAN2014'd  and A.SRVC_CURR_IND = 'Y' and A.ENCTR_CD NOT IN('3','4','U') and A.TRANS_CD ='00'

               group by MBR_SYS_ID

               having TOTAL_CLAIMS > 100000;

quit;


Accepted Solutions
Solution
‎06-25-2014 09:32 AM
Super User
Super User
Posts: 7,942

Re: Looking for YTD Claim Spend

I believe you need to subclause the where statement, then this would feed back into your outer loop for grouping.  Also, if you are still not getting anything then copy the subclause with the where into another proc sql, see what it returns.  Also you can try dropping the having and seeing what you get then.

proc sql;

     create table TOTAL_PAID as

     SELECT DISTINCT MBR_SYS_ID,

                                      SUM(SRC_PD_AMT) as TOTAL_CLAIMS

     FROM      (select *

                       from DB2.INS_CLAIM

                       WHERE A.CLM_PD_DT >= '01JAN2014'd  and A.SRVC_CURR_IND = 'Y' and A.ENCTR_CD NOT IN('3','4','U') and A.TRANS_CD ='00') A

      group by MBR_SYS_ID

      having TOTAL_CLAIMS > 100000;

quit;

View solution in original post


All Replies
Solution
‎06-25-2014 09:32 AM
Super User
Super User
Posts: 7,942

Re: Looking for YTD Claim Spend

I believe you need to subclause the where statement, then this would feed back into your outer loop for grouping.  Also, if you are still not getting anything then copy the subclause with the where into another proc sql, see what it returns.  Also you can try dropping the having and seeing what you get then.

proc sql;

     create table TOTAL_PAID as

     SELECT DISTINCT MBR_SYS_ID,

                                      SUM(SRC_PD_AMT) as TOTAL_CLAIMS

     FROM      (select *

                       from DB2.INS_CLAIM

                       WHERE A.CLM_PD_DT >= '01JAN2014'd  and A.SRVC_CURR_IND = 'Y' and A.ENCTR_CD NOT IN('3','4','U') and A.TRANS_CD ='00') A

      group by MBR_SYS_ID

      having TOTAL_CLAIMS > 100000;

quit;

Occasional Contributor
Posts: 9

Re: Looking for YTD Claim Spend

Ok, reran and checked------the total amount of claim spend is correct.

The query is returning all claims regardless of date but only calculating the total on 2014.

Is there a way to remove the results that are not applicable (2012-2013)?

Trusted Advisor
Posts: 1,228

Re: Looking for YTD Claim Spend

Are you sure you have members with total claims more than 100000 in 2014?

Occasional Contributor
Posts: 9

Re: Looking for YTD Claim Spend

Yes, I am trying to narrow down because I am returning many with over $1million because its pulling in 2012, 2013 etc.

Respected Advisor
Posts: 3,156

Re: Looking for YTD Claim Spend

Could "A.CLM_PD_DT"  be a "datetime" variable instead of "date" variable? Add  datepart( A.CLM_PD_DT) to see if produce what you are expecting.

Haikuo

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 272 views
  • 3 likes
  • 4 in conversation