Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 8593
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: 8057
Location: East Dubuque, Illinois, 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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us