Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SAS Question, I like to add one computer field to a Tot LIne

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: SAS Question, I like to add one computer field to a Tot LIne
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    Post subject: SAS Question, I need to add one Field to a Sub Total Line
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: 8657
Location: Back in jolly old England

PostPosted: Sat Feb 19, 2011 8:51 pm    Post subject:
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: 8280
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 19, 2011 9:00 pm    Post subject:
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

Site Director


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

PostPosted: Sun Feb 20, 2011 2:27 am    Post subject: Reply to: SAS Question, I like to add one computer field to
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts JES2 EXIT 6 QUESTION Randy Horowitz All Other Mainframe Topics 30 Tue Feb 06, 2018 5:47 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us