View previous topic :: View next topic
|
Author |
Message |
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi,
How can I sum a numeric field that has a sign and a decimal point using syncsort . For example, if my input file has:
251.91
241.23
289.72
231.78
-651.52
I want my output file to have:
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
I think you'll ned to reformat (using OUTREC?) to exclude the decpt, then sum that file, then reformat again to reinsert it.
Your example does not show decpt alignment, though, as your negative number's decpt is not aligned. In that case - much more complicated.
Is your example good? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Phrzby,
Its aligned only negetive sign in first byte for last record & others record are starting from second byte .
Would u please provide sort card for this? |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Ekta,
Why dont you try Sum a number with a decimal point from SORTTRCK pdf. Your requirement and the example provided by Frank in PDF are similar.
Let us know, if you need the PDF file. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Murali ,
I think u have not read my post i need the solution for syncsort not for dfsort
Hope i am clear |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Ekta,
If i understand correctly, the decimal point will always be in the same place?
If so, i believe you can do it in 2 passes - one pass with an inrec that copies the file skipping that data position and a second pass to sum the numbers without the decimal.
Given the same requirement, i would write a little COBOL program to do what i need - FWIW. Seems like so many of these "little" things, undergo "scope creep" and the new requirement definition needs real code.
Good Luck |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
I agree with Dick.
Use the right software tool so as your needs expand, you can change naturally, and those who inherit the system from you have a chance at knowing what's going on.
If you must use SORT, at least comment it (col1 = '*') with why and what you are doing. |
|
Back to top |
|
|
|