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

Sum and Avg for the records.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shanth555

New User


Joined: 17 Aug 2012
Posts: 35
Location: India

PostPosted: Thu Sep 06, 2012 1:32 pm
Reply with quote

Hi,

the dataset contains the records in this format.

Code:


00  978
01  683
02  442
03  274
04  255
05  235
06  296
07  471
08 1034
09 1571
10 2379


my output file should be like
Code:


Sum      Avg
8618      861.8   



Kindly let me know the tools to get this
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2012 1:34 pm
Reply with quote

Kindly let us know which Sort product you use and why you can't find the manual. Look at the TRAILERn functions.
Back to top
View user's profile Send private message
shanth555

New User


Joined: 17 Aug 2012
Posts: 35
Location: India

PostPosted: Thu Sep 06, 2012 2:20 pm
Reply with quote

i need the exact code to get this ouput
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2012 2:40 pm
Reply with quote

I agree. If your code is not exact, you can't expect it to work.

Quote:
Kindly let me know the tools to get this


To confirm the answer to your question: your Sort product can do this.

To give you a hint. Look at the TRAILER1 function. Has TOTAL and AVG.
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: Thu Sep 06, 2012 6:49 pm
Reply with quote

Hello and welcome to the forum,

Early on, you need to understand that the forum works best when you post sufficient information for someone to help you (what you believe is enough often is not).

You also need to provide the answers to requests for information. We do not ask just to entertain ourselves. The information requested is used to help you.

Quote:
i need the exact code to get this ouput
Yes, you surely do. (Re-read what Bill posted). And we will help you get to the "exact code". Our intention is to let you learn rather than doing the work for you.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Sep 06, 2012 9:05 pm
Reply with quote

Bill has given you indication, followed by Dick... Have you tried by writing some code using the SORT (product at your shop)? Did you get some error? Or faced some issue?
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: Thu Sep 06, 2012 9:21 pm
Reply with quote

Hi Anuj,

Unfortunately, this looks line another "newbie" who believes others should provide solutions so that learning is not really necessary . . . icon_sad.gif

d
Back to top
View user's profile Send private message
shanth555

New User


Joined: 17 Aug 2012
Posts: 35
Location: India

PostPosted: Fri Sep 07, 2012 6:53 pm
Reply with quote

Code:

//SYSIN    DD *                                           
     OUTFIL REMOVECC,NODETAIL,                             
            TRAILER1=((C'AVERAGE:',1:AVG=(07,03,ZD,M12))   
/*                                                         


getting sysntax error
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Sep 07, 2012 7:01 pm
Reply with quote

Can you show us the error? Can't do much otherwise.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Sep 07, 2012 7:04 pm
Reply with quote

Quote:
getting sysntax error

it would be nice if You would tell where

Quote:
i need the exact code to get this ouput

the TS wants us to provide it icon_cool.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Sep 07, 2012 7:09 pm
Reply with quote

At a guess, remove the "1:".

You seem to have forgotten any code for the total?
Back to top
View user's profile Send private message
shanth555

New User


Joined: 17 Aug 2012
Posts: 35
Location: India

PostPosted: Fri Sep 07, 2012 7:27 pm
Reply with quote

Code:

//STEP0006 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SYSPRINT DD SYSOUT=*                               
//SORTIN   DD DISP=SHR,DSN=G1OL00AT.QPRA.AFTR.MINU   
//SORTOUT  DD DSN=G1OL00AT.QPRA.AFTR.MINU.AVG,       
//            DISP=(OLD,CATLG,DELETE),               
//            SPACE=(CYL,(10,10),RLSE),               
//            DCB=(RECFM=FB,LRECL=50,BLKSIZE=27000)   
//SYSIN    DD *                                       
       SORT FIELDS=(1,4,CH,A)                         
       OUTFIL FNAMES=SORTOUT,NODETAIL,               
       SECTIONS=(01,04,                               
       TRAILER1=(C' AVG:',AVG=(81,08,ZD,EDIT=(TT.TT)))
/*                                                   



this is my code... pls tell me where i did wrong.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Sep 07, 2012 7:30 pm
Reply with quote

nahh icon_wink.gif

it's the m12 that sucks
and since the numbers are integers the TS will have to do some mangling

and... since I am in a very good mood here is a snippet ...

Code:
 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB (ACCT#),'SORT90',NOTIFY=ENRICO,
 000002 //             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)
 000003 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 000004 //*
 000005 //ICE     EXEC PGM=SORT
 000006 //SYSPRINT  DD SYSOUT=*
 000007 //SYSOUT    DD SYSOUT=*
 000008 //*4567890123456
 000009 //SORTIN    DD *
 000010 01       1
 000011 02      12
 000012 03     123
 000013 04    1234
 000014 05   12345
 000015 06   23456
 000016 07   34567
 000017 08   45678
 000018 09   56789
 000019 10   67890
 000020 //SORTOUT   DD SYSOUT=*
 000021 //SYSIN     DD *
 000022   OPTION COPY
 000023   INREC OVERLAY=(81:3,8,UFF,MUL,+100,M11,LENGTH=12)
 000024   OUTFIL REMOVECC,NODETAIL,
 000025          TRAILER1=('COUNT : ',COUNT=(M11,LENGTH=08),/,
 000026                    'SUM   : ',TOT=(81,12,UFF,EDIT=(TTTTTTTT.TT)),/,
 000027                    'AVG   : ',AVG=(81,12,UFF,EDIT=(TTTTTTTT.TT)))
 ****** **************************** Bottom of Data ****************************


adjust the positions and length accordingly
Back to top
View user's profile Send private message
shanth555

New User


Joined: 17 Aug 2012
Posts: 35
Location: India

PostPosted: Fri Sep 07, 2012 8:19 pm
Reply with quote

Thank You so Much Enrico

I would like to learn a lot from you... icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Sep 07, 2012 8:20 pm
Reply with quote

I am afraid You might not learn too much about sort from me icon_wink.gif
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: Fri Sep 07, 2012 8:41 pm
Reply with quote

Hello,

Good to hear it is working icon_smile.gif

When posting a problem like this one, you should post the JCL, control statements, and the diagnostics (including message numbers) generated by the run.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top