View previous topic :: View next topic
|
Author |
Message |
mmezzeld
New User
Joined: 28 Jan 2010 Posts: 2 Location: DC
|
|
|
|
SAS Question:
I have a file, for several Plans, Each Plan has number of Claims, and a Total Amount for each day.
I need to print a Report showing, Date, Number of Claims, Total Amount, and Average amount Per Claim.
All good, except when I try to print Total Claims, Total Amounts, and average amount/Claim for each Plan.
The following is my SAS code:
___________________________________________________
DATA TMONFILE;
INFILE TMONFILE;
INPUT @001 PROCDATE $10.
@012 PLAN_CODE $3.
@074 CLAIM_COUNT 9.
@084 PROC_TIME 9.;
PROC_TIME=PROC_TIME/100;
AVG_TIME = PROC_TIME / CLAIM_COUNT
*
*
TOTTIME = SUM(PROC_TIME);
TOTCLM = SUM(CLAIM_COUNT);
RUN;
PROC PRINT SPLIT='*' U NOOBS;
SUM CLAIM_COUNT
RUN;
PROC PRINT SPLIT='*' U NOOBS;
SUM CLAIM_COUNT
PROC_TIME;
ID PLAN_CODE;
BY PLAN_CODE;
VAR PLAN_CODE
CLAIM_COUNT
PROC_TIME
AVG_TIME;
RUN;
*
_____________________________________________________
The following is the result, I need to add Average for each Plan (= Sum of Proc Time/ sum of Claim Count))
=========================================
The SAS System 10:01 Saturday, F
PLAN_ PLAN_ CLAIM_ PROC_
CODE CODE COUNT TIME AVG_TIME
041 041 5 0.34 0.068
====== =====
5 0.34 ????
******************************* Bottom of Data ************ |
|
Back to top |
|
|
mmezzeld
New User
Joined: 28 Jan 2010 Posts: 2 Location: DC
|
|
|
|
SAS Question:
I have a file, for several Plans, Each Plan has number of Claims, and a Total Amount for each day.
I need to print a Report showing, Date, Number of Claims, Total Amount, and Average amount Per Claim.
All good, except when I try to print Total Claims, Total Amounts, and average amount/Claim for each Plan.
The following is my SAS code:
___________________________________________________
DATA TMONFILE;
INFILE TMONFILE;
INPUT @001 PROCDATE $10.
@012 PLAN_CODE $3.
@074 CLAIM_COUNT 9.
@084 PROC_TIME 9.;
PROC_TIME=PROC_TIME/100;
AVG_TIME = PROC_TIME / CLAIM_COUNT
*
*
TOTTIME = SUM(PROC_TIME);
TOTCLM = SUM(CLAIM_COUNT);
RUN;
PROC PRINT SPLIT='*' U NOOBS;
SUM CLAIM_COUNT
RUN;
PROC PRINT SPLIT='*' U NOOBS;
SUM CLAIM_COUNT
PROC_TIME;
ID PLAN_CODE;
BY PLAN_CODE;
VAR PLAN_CODE
CLAIM_COUNT
PROC_TIME
AVG_TIME;
RUN;
*
_____________________________________________________
The following is the result, I need to add Average for each Plan (= Sum
of Proc Time/ sum of Claim Count))
=========================================
PLAN_ PLAN_ CLAIM_ PROC_
CODE CODE COUNT TIME AVG_TIME
041 041 5 0.34 0.068
====== =====
5 0.34 ????
******************************* Bottom of Data ************
_________________ |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Take a look at PROC MEANS or PROC SUMMARY, might be an easier way. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Don't use PROC PRINT -- sometimes a data step is better.
Code: |
DATA TMONFILE;
INFILE TMONFILE;
INPUT @001 PROCDATE $10.
@012 PLAN_CODE $3.
@074 CLAIM_COUNT 9.
@084 PROC_TIME 9.;
PROC SORT DATA=TMONFILE; BY PLAN_CODE PROCDATE;
DATA _NULL_;
SET TMONFILE END=EOF;
BY PLAN_CODE PROCDATE ;
RETAIN TOTCLAIMS 0 TOTTIME 0;
FILE REPTFILE ... ;
IF FIRST.PLAN_CODE
THEN DO;
PLANCLAIMS = 0;
PLANTIME = 0;
END;
IF FIRST.PROCDATE
THEN DO;
DATECLAIMS = 0;
DATETME = 0;
END;
DATECLAIMS + CLAIM_COUNT;
DATETME + PROC_TIME ;
IF LAST.PROCDATE
THEN DO;
PLAINCLAIMS + DATECLAIMS;
PLANTIME + DATETME;
PUT 'DATE TOTALS ' PROCDATE ...
END;
IF LAST.PLAN_CODE
THEN DO;
TOTCLAIMS + PLANCLAIMS;
TOTTIME + PLANTIME;
PUT 'PLAN TOTALS ' PLAN_CODE ...
END;
IF EOF
THEN DO;
PUT 'TOTAL CLAIMS ' TOTCLAIMS ....
END;
|
and you can add the average calculations in the appropriate spots. The date totals roll up into the plan totals, which roll up into the grand totals. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Please remove your e-addr from your "signature".
There have been problems with "spamming" etc. . .
Thank you,
d |
|
Back to top |
|
|
|