Page 2 of 2

Re: SORT Card to sum the values of same-keys records

PostPosted: Tue Jul 30, 2013 2:47 pm
by vvkswm
Hi BillyBoyo,

Please can you tell me the difference between EQUALS and NOEQUALS?

Still I am confused about it.

Thanks,Vivek.

Re: SORT Card to sum the values of same-keys records

PostPosted: Tue Jul 30, 2013 3:11 pm
by NicC
As mentioned before there is NO "EQUALS" (or "NOEQUALS") in JCL. They are part of the SORT control records/cards. Please use the correct terminology. Also, you were asked to use the code tags when posting code/data. This is important to help present your data correctly as the correct spacing and alignment is maintained.

Re: SORT Card to sum the values of same-keys records

PostPosted: Tue Jul 30, 2013 3:59 pm
by BillyBoyo
Where keys are duplicate (keys being the fields on a SORT statement) EQUALS will preserve the input order through to output. NOEQUALS will output records with equal keys as is most convenient at the time (and which is unpredictable).
A1
A2
A3
B9
C8


If your SORT on 1,1,CH,A, with EQUALS you can guarantee that the A records will always be in the order 1,2,3. With NOEQUALS there is no guarantee. It might happen, it might not.

If you SUM, EQUALS is important if you want to base the final output on the first input record, from the input file, of that key.

It is all documented. Read the documentation, and ask if you are not clear about what is written.

Re: SORT Card to sum the values of same-keys records

PostPosted: Tue Jul 30, 2013 10:04 pm
by skolusu
vvkswm wrote:Hi,I tried the Below JCL with NOEQUALS.Then also the output is same as EQUALS.
Please can you explain me the use of EQUALS in jcl while sorting records.


wow really? Did you even read my prior response?

skolusu wrote:If you really want to see the difference between EQUALS and NOEQUALS you need to play with input that has more duplicates.


I have no idea why people are so persistent on trying to prove EQUALS and NOEQUALS gets the same results.

Run this JCL and pay attention to the 6th byte, which is in the ascending order. I am sorting on the first 3 bytes which is basically the word "key" for every record.

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
KEY0 A                                                               
KEY3 B                                                               
KEY4 C                                                               
KEY1 D                                                               
KEY2 E                                                               
KEY3 F                                                               
KEY4 G                                                               
KEY5 H                                                               
KEY6 I                                                               
KEY7 J                                                               
KEY0 K                                                               
KEY0 L                                                               
KEY0 M                                                               
KEY0 N                                                               
KEY0 O                                                               
KEY0 P                                                               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC OVERLAY=(250:C'VVKSWM STRONGLY BELIEVES EQUALS HAS NO VALUE')
  SORT FIELDS=(1,3,CH,A),NOEQUALS                                     
//*


Copy the output and now re-run the job with EQUALS and then compare the output.

P.S: If you strongly believe that EQUALS and NOEQUALS makes no difference to the order of the Output , you can stop coding it and get burned. It is up to you. Good Luck

Re: SORT Card to sum the values of same-keys records

PostPosted: Wed Jul 31, 2013 4:42 pm
by vvkswm
Hi skolusu,

I tried the above JCL Using both EQUALS & NOEQUALS, But output is same in both the case.

Please can you tell me why it is showing like this.

Output of above JCL:
EQUALS     NOEQUALS
KEY0 A      KEY0 A
KEY3 B      KEY3 B
KEY4 C      KEY4 C
KEY1 D      KEY1 D
KEY2 E      KEY2 E
KEY3 F      KEY3 F
KEY4 G      KEY4 G
KEY5 H      KEY5 H
KEY6 I      KEY6 I
KEY7 J      KEY7 J
KEY0 K      KEY0 K
KEY0 L      KEY0 L
KEY0 M      KEY0 M
KEY0 N      KEY0 N
KEY0 O      KEY0 O
KEY0 P      KEY0 P

Thanks,
VIvek.

Re: SORT Card to sum the values of same-keys records

PostPosted: Wed Jul 31, 2013 4:50 pm
by NicC
Once again you have failed to use the code tags so your table was all to pieces. I have coded it for you but this is the last time.

Re: SORT Card to sum the values of same-keys records

PostPosted: Wed Jul 31, 2013 5:32 pm
by BillyBoyo
With EQUALS the order for duplicate keys is predictable.

With NOEQUALS the order for duplicate keys is whatever DFSORT feels like at the time.

Show the sysout for both steps, inside the code tags please.

If you really believe there is no difference, use NOEQUALS where the order of duplicate keys is important for your work, and wait for the complaints.

If all input keys are unique, you get sorted output which is no affected by EQUALS.

If you have non-unique keys, all the output will be in key order - in addition, for the non-unique keys (any unique keys in the same dataset are unaffected), with EQUALS the output for non-unique keys will be in "input order", with NOEQUALS the output will be whatever is most convenient at the time for DFSORT.

Re: SORT Card to sum the values of same-keys records

PostPosted: Wed Jul 31, 2013 10:42 pm
by skolusu
vvkswm wrote:Hi skolusu,

I tried the above JCL Using both EQUALS & NOEQUALS, But output is same in both the case.

Please can you tell me why it is showing like this.


vvkswm,

You sure that you are indeed SORTING and not COPYing the data? I need to see the complete Sysout from both the Jobs.

I have no idea as to why you want to increase the font to stress the parms. We get it and you don't have to shout it aloud.

Either way unless you are showing us the complete sysout, I am not going to spend any more time on this issue.