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

MIN and MAX functions in SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Tue Feb 27, 2007 1:58 pm
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: 1208
Location: Bangalore,India

PostPosted: Tue Feb 27, 2007 2:35 pm
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 Developer


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

PostPosted: Tue Feb 27, 2007 10:27 pm
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

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Wed Feb 28, 2007 6:16 am
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 Developer


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

PostPosted: Wed Feb 28, 2007 8:49 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top