Posted: Wed Jan 04, 2006 4:15 pm Post subject: Horizontal Summing
If in the input dataset has records
Code:
ABC A1 JAN 1
ABC A1 JAN 2
ABC A2 JAN 1
ABC A2 JAN 2
ABC A3 JAN 1
ABC A3 FEB 2
ABC A3 MAR 3
ABC A4 JAN 1
ABC A4 FEB 2
ABC A4 MAR 3
How can it be grouped based on ABC code ,then on A1,A2,A3,A4 is there any concept of grouping where in we can achieve the group results like
Code:
ABC A1 JAN 1 2
A2 JAN 1 2
A3 JAN 1 2 3
A4 JAN 1 2 3
Also Can we sum the fields in horizantally like
Code:
SUM
ABC A1 JAN 1 2 3
A2 JAN 1 2 3
A3 JAN 1 2 3 6
A4 JAN 1 2 3 6
----
18
In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.
For the second question you can use HORIZONTAL MATH functions(add) to get the desired results. Let us know the format and position of the fields and we will show you how to do it.
ABC is CHARACTER DATA
A1,A2,A3,A4 is CHARACTER DATA
JAN,FEB,MAR is CHARACTER DATA
1,2,3 is NUMERIC DATA (But while displaying on the report numeric data should be edited)
Code:
----+----1---
ABC A1 JAN 1
ABC A1 JAN 2
ABC A2 JAN 1
ABC A2 JAN 2
ABC A3 JAN 1
ABC A3 FEB 2
ABC A3 MAR 3
ABC A4 JAN 1
ABC A4 FEB 2
ABC A4 MAR 3
My queries:
1.How can we add horizantally the numeric data.
2.In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.
3.I have searched the link given by you for grouping the values and i find that ICETOOL / SYNCTOOL is being used.Can we achieve the results using SORT only in a single step as i am using SORT for other purposes and i want to acompilish the task in a single step.
4.I am using the syntax REMOVECC in the control statements ,but still the output spool is of 81 bytes and if i use 40:c'FINISH', the code starts from 41 st column ,why is the output 81 bytes instead of 80 bytes.
Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
Posted: Thu Jan 05, 2006 1:15 pm Post subject:
Quote:
4.I am using the syntax REMOVECC in the control statements ,but still the output spool is of 81 bytes and if i use 40:c'FINISH', the code starts from 41 st column ,why is the output 81 bytes instead of 80 bytes.
Mfuser,
Please do NOT combine questions related to 2 different topics. Your question 4 is not at all related to this question. Please post it in the other topic.
The contents at pos 5,7,9,11 each of 1 byte of zoned decimal format is added as a single variable and written as 4 byte sum field.
Quote:
2.In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.
There are different ways to do it depending on the max no: of rows present for each key.
Quote:
3.I have searched the link given by you for grouping the values and i find that ICETOOL / SYNCTOOL is being used.Can we achieve the results using SORT only in a single step as i am using SORT for other purposes and i want to acompilish the task in a single step.
If you had read the entire thread completely you would have found this solution posted by frank.
My understanding is not very clear about grouping the data.Can you please guide me how to group this sample input data to desired format so that i can proceed ahead further.
Code:
----+----1---
ABC A1 JAN 1
ABC A1 JAN 2
ABC A2 JAN 1
ABC A2 JAN 2
ABC A3 JAN 1
ABC A3 FEB 2
ABC A3 MAR 3
ABC A4 JAN 1
ABC A4 FEB 2
ABC A4 MAR 3
Desired Output
Code:
ABC A1 JAN 1 2
A2 JAN 1 2
A3 JAN 1 2 3
A4 JAN 1 2 3
In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.Please show me a sample syntax from where in i can build my own code.
Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
Posted: Thu Jan 05, 2006 2:13 pm Post subject:
Mfuser,
Quote:
ABC A1 JAN 1 2
A2 JAN 1 2
A3 JAN 1 2 3 A4 JAN 1 2 3
How did you group the records for A3 and A4 keys? They don't have Jan 2 and Jan 3. Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.
In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check in the input dataset whether there is a 3 rd value for individual A1 / A2 / A3 /A4 ? If it is blank display blank in the report ,if it has a non blank data then display non blank data it in the report and the data is numeric ?
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Jan 05, 2006 4:26 pm Post subject:
mfuser,
Does your fourth column of data really have only 1, 2 or 3 in that order or can it be any number, e.g.
Code:
ABC A1 JAN 5
ABC A1 JAN 9
ABC A2 JAN 8
ABC A2 JAN 3
ABC A3 JAN 7
...
Kolusu,
I don't think your solution will work if the fourth column can have any numbers.
In case anyone is interested, here's a DFSORT solution that works with any numbers in the fourth column and also shows the ABC only for the first record as requested. I didn't bother to put in the headers (wasn't sure if they were really wanted), but they're easy enough to add.
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
Posted: Thu Jan 05, 2006 5:21 pm Post subject:
Quote:
Kolusu,
I don't think your solution will work if the fourth column can have any numbers.
Frank I am aware of that, but OP hasn't actually provided complete details. I Knew that restart with overlay will be the best solution for this, which unfortunately I cannot test it.
As per Frank's note my fourth column can have any value as it is being retreived from a table not necessarily 1/ 2/3 it can have anything.Morever can the desired result be produced by SORT only instead of ICETOOL as i am using SORT for other purposes.
Kolusu,When i have run the code , i am getting syntax error ,is it because ADD function is not available with the verison of SORT which i am using in my shop and i am using DFSORT REL 14.0
I have tried out the code provided by both of you in a later version of DFSORT--- Z/OS DFSORT V1R5 and both of the codes have worked out perfectly with the desired inputs and outputs.I have a query whether can i achieve the same results using SORT only instead of ICETOOL because i have am using SORT to display DATE ,TIME and HEADERS and PAGE numbers also and some other processing.I am not well conversant with ICETOOL.How can i achieve the DATE,TIME,PAGE,HEADERS repeating and TRAILER.
Joined: 26 Nov 2002 Posts: 12395 Topics: 75 Location: San Jose
Posted: Fri Jan 06, 2006 7:45 am Post subject:
Quote:
I have a query whether can i achieve the same results using SORT only instead of ICETOOL
This has been already answered. May be you missed it. So let me tell you in a programming language
Code:
DO UNTIL talking parrot = TIRED
NO NO NO YOU CANNOT GET THE SAME RESULTS USING ONLY SORT INSTEAD OF ICETOOL
END-DO
Quote:
I am not well conversant with ICETOOL.
Well you can start learning it and trust me it is NOT greek and latin. Frank has made it much easier with an excellent docuementation which can be found here
I will try to get the desired results using ICETOOL only and the links provided by you are very good and informative.I will make it as a practise exercise for me and i will surely learn using ICETOOL and it will definetly help me in the future.Thanks.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum