I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?
Input file:
134569999 <- need to sum position starting in 6 for length of 4
134568888 <- need to sum position starting in 6 for length of 4
299993332654 <- need to sum position starting in 9 for length of 4
299995448734 <- need to sum position starting in 9 for length of 4
Output file:
1 - $188.87
2 - $113.88
Also, is there a way to change the output file to reflect a more meaningful description, e.g., instead of 1 it can display "Total Charges" or instead of 2, it can display "Total Waived Charges".
I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?
Input file:
134569999 <- need to sum position starting in 6 for length of 4
134568888 <- need to sum position starting in 6 for length of 4
299993332654 <- need to sum position starting in 9 for length of 4
299995448734 <- need to sum position starting in 9 for length of 4
1. If "you are trying something" then where are any results of your attempts???
2. Your "description" of input file (e.g., dataset) doesn't clarify what you really want to do.
3. How come that from 4 input positions you produced 5 output digits, plus decimal point, plus dollar sign?
I'm trying to sum amounts in position 6 for the first two records and sum amounts in position 9 for the next two records (since they have the same character in position 1). And, would like it formatted to include a dollar sign and decimal point.
NOT sure I understand you......I can't get this to work, so i don't hane any results, which is why I'm on the site. Secondly, i'm trying to sum the total amount of "Direct Charges" and "Waived Charges"....does this help you?
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
Quote:
I can't get this to work, so i don't hane any results,
Are you getting a JCL error? Are you not getting a JCL error but not getting any output? Are you getting SYNCSORT (WER) messages in your output? What, precisely, are you doing and what results are you getting?
If you have not yet even attempted to code and test yourself, be aware that this is a HELP forum, NOT a WRITE-THE-CODE-FOR-YOU forum. When you start posting job output and error messages, you'll get vastly better help. Until then, there's nothing more that we can do for you (this is a forum for professionals, who are supposed to know how to write sort utility statements and get output). You may be better off on Beginners and Students Forum although you will still need to code and run something to get meaningful feedback.
Ok, thanks for the honest feedback. This is my first attempt on this website as I usually find the answers to what I need. Furthermore, below is my code, which works but doesn't give me the results I expect (see above).
Thanks for the info...I'm a step closer when I changed OUTREC to INREC; however, I changed the SUM Fields to
SUM FIELDS=(25,11,ZD,M4)
and received a WER268A error....basically stating edit masks cannot be used in a SUM statement.
Also, I need the include clause as the records I need summed have 98 starting in position 2 (but it should be length of 2 NOT 4...sorry). I'm NOT as familiar with Sections but will read the manual and research this on the internet.
Look at the input records you shared to us. Where is it showing 98 in it starting at 2 ?
If you want to use include on summed value then you need to use OUTFIL and INCLUDE. This current include will be applied prior to SUM.
You can use Edit in outrec build instead of using it in SUM FIELDS.
Instead of ZD use UFF OR SFF and you need to do that EDIT in OUTREC after SUM FIELDS and not in INREC.
INREC is only to rearrange SUM positions at same place nothing else. Do all the EDITS in OUTREC BUILD.
I'm trying to sum records with amounts in different positions based on the first character of the file. Can this be accomplished in SyncSort?
OMG!!!
If you really need to summarize values within groups (are the records already grouped as needed? are there always only two groups in your data? Are there always only two records in each group?) - then you need to use the statement
OUTFIL …,SECTIONS=(…)
With the statement SUM you can only get a single sum of values through all your table/file/dataset, not separated by groups.
P.S.
Did you ever read ANY SORT manual in your life?
This topic looks like
Quote:
I'm trying to organize a mission to Mars with different equipment sent to the planet. Can this be accomplished in my company?