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
 

 

Help on AVG function in SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
RGiri

New User


Joined: 09 Nov 2009
Posts: 3
Location: Chennai, India

PostPosted: Tue Nov 10, 2009 10:51 am    Post subject: Help on AVG function in SORT
Reply with quote

Hi,

I am trying to find the average of the quantity field from the input records. The SORT CARD that I coded is not displaying the decimal values correctly.

Below are the input records.

STR01-STK01-QTY01-TERR01
STR01-STK01-QTY02-TERR01
STR03-STK01-QTY03-TERR01
STR01-STK02-QTY01-TERR02
STR01-STK02-QTY02-TERR02
STR01-STK02-QTY03-TERR02

Below is the SORT CARD.

SORT FIELDS=(07,05,CH,A,19,06,CH,A)
OUTFIL FNAMES=SORTOUT,NODETAIL,
SECTIONS=(01,05,
TRAILER3=(01,25,C' TOT:',TOT=(16,02,ZD,EDIT=(TTT)),
C' CNT:',COUNT=(M11,LENGTH=02),
C' AVG:',AVG=(16,02,ZD,EDIT=(TT.TT))))

The output of the above SORT card is:

STR01-STK01-QTY02-TERR01 TOT:003 CNT:02 AVG:00.01
STR03-STK01-QTY03-TERR01 TOT:003 CNT:01 AVG:00.03
STR01-STK02-QTY03-TERR02 TOT:006 CNT:03 AVG:00.02

Expected output is:

STR01-STK01-QTY02-TERR01 TOT:003 CNT:02 AVG:01.50
STR03-STK01-QTY03-TERR01 TOT:003 CNT:01 AVG:03.00
STR01-STK02-QTY03-TERR02 TOT:006 CNT:03 AVG:02.00
Back to top
View user's profile Send private message

Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2180
Location: @my desk

PostPosted: Tue Nov 10, 2009 12:48 pm    Post subject:
Reply with quote

Giri,

You may try the below card.
Code:
//SYSIN    DD *                                     
  INREC OVERLAY=(81:16,2,ZD,MUL,+100,M11,LENGTH=8)   
  SORT FIELDS=(07,05,CH,A,19,06,CH,A)               
  OUTFIL FNAMES=SORTOUT,NODETAIL,                   
  SECTIONS=(01,05,                                   
  TRAILER3=(01,25,C' TOT:',TOT=(16,02,ZD,EDIT=(TTT)),
  C' CNT:',COUNT=(M11,LENGTH=02),                   
  C' AVG:',AVG=(81,08,ZD,EDIT=(TT.TT))))             
//*     
Back to top
View user's profile Send private message
RGiri

New User


Joined: 09 Nov 2009
Posts: 3
Location: Chennai, India

PostPosted: Tue Nov 10, 2009 3:42 pm    Post subject: Reply to: Help on AVG function in SORT
Reply with quote

Arun Raj,

Thank you. The SORT card that you gave is working and it is giving me the expected result.
But I am not sure why we are mutiplying the input data by 100 before averaging. Am I missing something about the AVG function?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Nov 11, 2009 12:11 am    Post subject:
Reply with quote

AVG only displays an integer value, not a decimal value.

So if you have 21/8, it will be displayed as 2, not as 2.625. If you want to display the decimal part, you have to multiply by the appropriate value (e.g. +100 for two decimal places or +1000 for three decimal places).
Back to top
View user's profile Send private message
RGiri

New User


Joined: 09 Nov 2009
Posts: 3
Location: Chennai, India

PostPosted: Wed Nov 11, 2009 9:31 am    Post subject: Reply to: Help on AVG function in SORT
Reply with quote

Frank Yaeger,

Thanks a lot for the clarification.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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