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
 

 

MIN and MAX functions in SORT

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

New User


Joined: 31 Oct 2006
Posts: 23
Location: brisbane

PostPosted: Tue Feb 27, 2007 1:58 pm    Post subject: MIN and MAX functions in SORT
Reply with quote

I have an input file that resembles the following :

id_____d1_______d2

01 aaa 2001-01-01 2002-01-01
01 aaa 1999-01-01 2003-01-01
02 bbb 2001-03-03 2005-03-03
02 bbb 2001-02-03 2005-03-03
02 bbb 2001-03-03 2005-03-04

the records are grouped on id. I want one row for each group showing the min date of d1 and the max date of d2.

so for the above input I would expect the following -

01 aaa 1999-01-01 2003-01-01
02 bbb 2001-02-03 2005-03-04
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Tue Feb 27, 2007 2:35 pm    Post subject:
Reply with quote

Hi There,



Code:
//STEP01   EXEC PGM=SYNCTOOL                                   
//SYSOUT   DD SYSOUT=*                                         
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN1 DD *                                                     
01 aaa 2001-01-01 2002-01-01
01 aaa 1999-01-01 2003-01-01
02 bbb 2001-03-03 2005-03-03
02 bbb 2001-02-03 2005-03-03
02 bbb 2001-03-03 2005-03-04
/*                                                             
//OUT1 DD SYSOUT=*                                             
//TEMP DD DSN=&T1,UNIT=TEST,SPACE=(CYL,(5,5)),DISP=(,PASS)     
//TOOLIN DD *                                                 
  SORT FROM(IN1) USING(CTL1)                                   
  SORT FROM(TEMP) TO(OUT1) USING(CTL2)                         
/*                                                             
//CTL1CNTL DD *                                               
   SORT FIELDS=(1,2,CH,A,4,3,CH,A,8,10,CH,A,19,10,CH,D)                             
   OUTFIL FNAMES=TEMP                                         
/*                                           
//CTL2CNTL DD *                               
   SORT FIELDS=(1,2,CH,A,4,3,CH,A)                     
   SUM FIELDS=NONE                       
/* 

I Have not tested it since i do not have dfsort in my shop .
I can provide u two step syncsort job to solve this if needed
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: Tue Feb 27, 2007 10:27 pm    Post subject:
Reply with quote

jzhardy,

Here's a DFSORT job that will do what you asked for in one copy pass:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,7,
      TRAILER3=(1,7,
        MIN=(8,10,UFF,EDIT=(TTTT-TT-TT)),X,
        MAX=(19,10,UFF,EDIT=(TTTT-TT-TT))))
/*
Back to top
View user's profile Send private message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 23
Location: brisbane

PostPosted: Wed Feb 28, 2007 6:16 am    Post subject:
Reply with quote

thanks - works fine!

btw - i put this within an ICETOOL control statement. is there any addtional overhead in using ICETOOL vs ICEMAN ?
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 Feb 28, 2007 8:49 pm    Post subject:
Reply with quote

Quote:
is there any addtional overhead in using ICETOOL vs ICEMAN ?


It would be insignificant. But if you're worried, you could try it both ways and compare.
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 Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


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