View previous topic :: View next topic
|
Author |
Message |
abby.qiong.zhang
New User
Joined: 07 Jun 2012 Posts: 26 Location: China
|
|
|
|
Please help with the SUM function, my input like this:
Code: |
0400022M0000142000693 000300
0400022M1000142000693 000300
0400022M1000142000693 000030
0400022M2000142000693
0004088M0000142000691 000100
0004088M1000142000691 000100
0004088M2000142000691
0004088M0000142000694 000400
0004088M1000142000694 000400
0004088M2000142000694
|
For 'M1' records, i need to summarize the amount 000300 and 000030 together, for other records, keep the same.
The output should like this:
Code: |
0400022M0000142000693 000300
0400022M1000142000693 000330
0400022M2000142000693
0004088M0000142000691 000100
0004088M1000142000691 000100
0004088M2000142000691
0004088M0000142000694 000400
0004088M1000142000694 000400
0004088M2000142000694
|
I tried with the statements like this:
Code: |
SORT FIELDS=(1,3,CH,D,15,8,CH,A,8,2,CH,A,10,4,CH,A,4,4,CH,A)
SUM FIELDS=(134,6,PD)
OPTION EQUALS
|
But the output is not what I want, the M2 record will before the M1 record like this:
Code: |
0400022M0000142000693 000300
0400022M2000142000693
0400022M1000142000693 000330
0004088M0000142000691 000100
0004088M2000142000691
0004088M1000142000691 000100
0004088M0000142000694 000400
0004088M2000142000694
0004088M1000142000694 000400
|
Can anyone help? Thanks! |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Try adding a sequence number before sum and after sum sort it based on sequence number |
|
Back to top |
|
|
abby.qiong.zhang
New User
Joined: 07 Jun 2012 Posts: 26 Location: China
|
|
|
|
Pandora-Box wrote: |
Try adding a sequence number before sum and after sum sort it based on sequence number |
Thanks Pandora-Box for your quick response! Can you give me a sample about how to use SEQNUM? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Your sort card does not <visually> match the input ...
15,8,ch,a sorts one <extra> char after the visible ones
Code: |
position ==>123456789012345678901
sort keys ==>1115555334444 22222222
data ==>0400022M0000142000693 000300
* |
|
|
Back to top |
|
|
abby.qiong.zhang
New User
Joined: 07 Jun 2012 Posts: 26 Location: China
|
|
|
|
enrico-sorichetti wrote: |
Your sort card does not <visually> match the input ...
15,8,ch,a sorts one <extra> char after the visible ones
Code: |
position ==>123456789012345678901
sort keys ==>1115555334444 22222222
data ==>0400022M0000142000693 000300
* |
|
Thanks Enrico, yeah, i made a mistake, it should be
I tried again, and get the output I want.
Code: |
0400022M0000142000693 000330
0400022M1000142000693 000330
0400022M2000142000693
0004088M0000142000691 000100
0004088M1000142000691 000100
0004088M2000142000691
0004088M0000142000694 000400
0004088M1000142000694 000400
0004088M2000142000694
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
that confirm my ( and many other's opinion )
more than 90% of errors can be found by simple(*) VISUAL inspection
(*) just rereading, no complicate walk thru! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Now how did the M0 get "summed" to become 330? |
|
Back to top |
|
|
abby.qiong.zhang
New User
Joined: 07 Jun 2012 Posts: 26 Location: China
|
|
|
|
Bill Woodger wrote: |
Now how did the M0 get "summed" to become 330? |
It's a typo. |
|
Back to top |
|
|
|