Page 1 of 1

conditioning - ifthen

PostPosted: Fri Mar 19, 2010 7:38 pm
by smellslikeroses
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

Re: conditioning - ifthen

PostPosted: Fri Mar 19, 2010 8:15 pm
by Alissa Margulies
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.

Re: conditioning - ifthen

PostPosted: Fri Mar 19, 2010 10:23 pm
by smellslikeroses
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

Re: conditioning - ifthen

PostPosted: Fri Mar 19, 2010 11:28 pm
by Alissa Margulies
Which release and maintenance level of SyncSort for z/OS are you running?

Re: conditioning - ifthen

PostPosted: Fri Mar 19, 2010 11:43 pm
by smellslikeroses
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

Re: conditioning - ifthen

PostPosted: Sat Mar 20, 2010 12:29 am
by Alissa Margulies
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)                   
/*