BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jls954
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

jls954
Calcite | Level 5

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)?

stat_sas
Ammonite | Level 13

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

jls954
Calcite | Level 5

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

Haikuo
Onyx | Level 15

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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