Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum 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: 8796
Location: Welsh Wales

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: 8556
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

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19254
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 do i verify the char field is hav... Raghu M N PL/I & Assembler 1 Tue Sep 22, 2020 9:26 pm
No new posts RPLDDDD field for extended VSAM - ESDS amitsjcntl JCL & VSAM 0 Tue Sep 22, 2020 1:45 pm
No new posts Am Getting a vertical line in ISPF SC... Himansu22 TSO/ISPF 3 Fri Jul 31, 2020 11:58 pm
No new posts Question for Cobol Report Writer jackzhang75 COBOL Programming 3 Wed May 27, 2020 4:35 am
No new posts Print next line strings when a condit... tgmuntor DFSORT/ICETOOL 9 Wed May 20, 2020 9:08 pm

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