IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SAS Question, I like to add one computer field to a Tot LIne


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mmezzeld

New User


Joined: 28 Jan 2010
Posts: 1
Location: DC

PostPosted: Sat Feb 19, 2011 8:38 pm
Reply with quote

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
View user's profile Send private message
mmezzeld

New User


Joined: 28 Jan 2010
Posts: 1
Location: DC

PostPosted: Sat Feb 19, 2011 8:44 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Sat Feb 19, 2011 8:51 pm
Reply with quote

Take a look at PROC MEANS or PROC SUMMARY, might be an easier way.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 19, 2011 9:00 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Feb 20, 2011 2:27 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Question for file manager IBM Tools 7
No new posts rewrite same SAY line CLIST & REXX 8
Search our Forums:

Back to Top