conditioning - ifthen



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

conditioning - ifthen

Postby smellslikeroses » Fri Mar 19, 2010 7:38 pm

Dont know if this is possible. It is not a question of duplicates, instead it is a conditioning question
I can do this easy in Cobol but the requirement is instream SAS or Syncsort (I prefer SyncSort)
Need to count column 1 occurances where C2 or C3 changes:
if C2 (column 2) changes but (column 1) does not change this is an occurance to count
OR
when both Column 1 and Column 2 change - this also is an occurance to count.
Basically I am trying to find the number of times column 1 is repeated for different column2's

So in the following:

A1 C123C456
A2 C123C456
A3 C123C456
A1 C123C457
A1 C123C457
A2 C123C456
A1 C123C457
A3 C123C457

the result would be:
Count column added to output
A1 C123C456 3
A1 C123C457 3
A1 C123C457 3
A1 C123C458 3
A2 C123C456 2
A2 C123C457 2
A3 C123C456 1
A3 C123C456 1

I know it would include ifthen and restart for the counts but not sure how to tackle this
smellslikeroses
 
Posts: 12
Joined: Fri Mar 12, 2010 7:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: conditioning - ifthen

 

Re: conditioning - ifthen

Postby Alissa Margulies » Fri Mar 19, 2010 8:15 pm

The data in your sample input records do not match your output records. Please re-post your records so that we can properly answer your question.
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 1 time

Re: conditioning - ifthen

Postby smellslikeroses » Fri Mar 19, 2010 10:23 pm

ok
Original unsorted file contents
A1  C123C456
A2  C123C456
A3  C123C456
A1  C123C457
A1  C123C457
A2  C123C457
A1  C123C458
A3  C123C456


Sorted (Sort by Column 1,2,3) contents with count applied:
A1  C123C456 3
A1  C123C457 3
A1  C123C457 3
A1  C123C458 3
A2  C123C456 2
A2  C123C457 2
A3  C123C456 1
A3  C123C456 1
smellslikeroses
 
Posts: 12
Joined: Fri Mar 12, 2010 7:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: conditioning - ifthen

Postby Alissa Margulies » Fri Mar 19, 2010 11:28 pm

Which release and maintenance level of SyncSort for z/OS are you running?
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 1 time

Re: conditioning - ifthen

Postby smellslikeroses » Fri Mar 19, 2010 11:43 pm

not sure where I could quickly find the maintenance level but ...
1 SYNCSORT FOR Z/OS 1.3.2.0R U.S. PATENTS: 4210961, 5117495 (C) 2007 SYNCSORT
smellslikeroses
 
Posts: 12
Joined: Fri Mar 12, 2010 7:34 am
Has thanked: 0 time
Been thanked: 0 time

Re: conditioning - ifthen

Postby Alissa Margulies » Sat Mar 20, 2010 12:29 am

Here is one way to accomplish this task:
//STEP1 EXEC PGM=SORT                                               
//SORTIN  DD *                                                     
A1 C123C456                                                         
A2 C123C456                                                         
A3 C123C456                                                         
A1 C123C457                                                         
A1 C123C457                                                         
A2 C123C457                                                         
A1 C123C458                                                         
A3 C123C456                                                         
//SORTOUT DD DISP=(NEW,PASS),DSN=&&TEMP                             
//SYSOUT  DD SYSOUT=*                                               
//SYSIN   DD *                                                     
  SORT FIELDS=(1,11,CH,D)                                           
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(13:SEQNUM,1,ZD,RESTART=(1,11))),
         IFTHEN=(WHEN=(13,1,ZD,NE,1),OVERLAY=(13:C'0'))             
  OUTFIL SECTIONS=(1,2,TRAILER3=(13:TOT=(13,1,ZD,EDIT=(T)))),REMOVECC
/*                                                                 
//STEP2 EXEC PGM=SORT                                                                   
//SYSOUT  DD SYSOUT=*                                             
//SORTOUT DD SYSOUT=*                                             
//SORTIN  DD DISP=SHR,DSN=&&TEMP                                 
//SYSIN   DD *                                                   
  INREC OVERLAY=(15:SEQNUM,8,ZD)                                 
  SORT FIELDS=(15,8,CH,D)                                         
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C' '),PUSH=(13:13,1))
  OUTFIL INCLUDE=(1,1,CH,NE,C' '),BUILD=(1,13)                   
/*                                                               
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 1 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post