View previous topic :: View next topic
|
Author |
Message |
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
Hi Guys,
I have a file which has some data I need to count.
Example.
Input File:
000A
000A
000B
000A
000C
Output File:
A Recs: 03
B Recs: 01
C Recs: 01
I know how to count the records and put them into a file but in different files. I only want a single output file for this.
Code: |
SORT FIELDS=COPY
OUTFIL FILES=01,
INCLUDE=(4,1,CH,EQ,C'A'),
REMOVECC,NODETAIL,
TRAILER1=('A RECS:',COUNT=(EDIT=(TT))) |
btw we are using SYNCSORT FOR Z/OS 1.3.2.1R |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Quote: |
I need a guide or hint to start with so I won't waste more time and resources in finding the correct answer if there is one.
|
Michael,
What you want to do can be done (in more than one way).
If you spend your time trying (start with what you have), you are not wasting it. Even if it was not possible, the experience you gain, and the effort you expell makes it worth while.
I may get a dozen or more failed attempts with syncsort before I get it to work.
Thomas Edison had hundreds of failed experiments for something that was not possible for each successful patent.
With regard to wasted resources, in my opinion, the computer sitting idle, instead of helping you with your experiment is the wasted resource, not the other way around. |
|
Back to top |
|
|
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
thanks for the insight dave
I am trying some other methods but I just want to achieve this in a single step.
also, I can only run this on the company's machine and just can't experiment all day because I have some other things to do.
I am not that proficient with SORT (esp new functions), so I just need some guide on how to do it the simplest way.
thanks again |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Quote: |
also, I can only run this on the company's machine and just can't experiment all day because I have some other things to do.
|
Me too. |
|
Back to top |
|
|
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
any other informative comments? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Which release of Syncsort is being used? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Michael,
With the sort card, you show - you'll get
in output and not
Code: |
A Recs: 03
B Recs: 01
C Recs: 01 |
And 'am not sure about this:
Quote: |
I know how to count the records and put them into a file but in different files. I only want a single output file for this. |
Does the quoted text mean, you want the output like:
Code: |
000A
000A
000B
000A
000C
A Recs: 03
B Recs: 01
C Recs: 01 |
Please explain. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
Michael wants the counts of the different "types" all in one output.
He knows how to get a single count in a trailer and does not want to create 3 sets of trailer code. . . |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Michael,
You're almost there. Changing your card as below might help(Untested).
Code: |
SORT FIELDS=(4,1,CH,A)
OUTFIL REMOVECC,NODETAIL,SECTIONS=(4,1,
TRAILER3=(4,1,' RECS:',COUNT=(EDIT=(TT)))) |
Remember, the output will be routed to SORTOUT as opposed to your job which writes into SORTOF01 |
|
Back to top |
|
|
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
thank you dick and arun for your assistance.
I will try the sort card above once I get back to the office. I'll try to understand the SECTION parameter on the manual I asked from Ms. Alissa..
but seeing the sort card..is it correct to assume that the SECTION somewhat groups similar string of char based on the sort fields?
again thanks guys |
|
Back to top |
|
|
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
I made a quick test and the sort card is giving me the expected output.
Thank you Arun.
Another question...if my input varies a little bit..like the position fields of the type/value needed to be counted are not the same for all the records
e.g.
Input File:
000A
000A
XXXX000B
000A
XXXX000C
Output File:
A Recs: 03
B Recs: 01
C Recs: 01
Can this still be achieved by a single step?
thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
if my input varies a little bit.. |
This additional requirement is more than a "little bit". . . It basically negates the working solution. . .
Post any additional "requirement info" now so no one wastes time on a solution that won't be used.
What are the rules for finding the "keys". If there are no rules, it probably cannot be done. . . |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the approach has beed discussed a few times
using the BUILD IFTHEN constructs build an auxiliary field
carry on the grouping on that field and as per current approach
when writing the final result just ignore the auxiliary field
for example
if the record is 80 bytes build the auxiliary field at position 81 for the relevant number of bytes
searching the forums for BUILD IFTHEN will give quite a few examples
on how to proceed |
|
Back to top |
|
|
Michael Angelo Pagala
New User
Joined: 02 Mar 2007 Posts: 34 Location: somewhere in the middle
|
|
|
|
yes I was aware of that dick and I apologize for that..I will probably do enrico's suggestion.
thanks again guys..you have been so helpful! |
|
Back to top |
|
|
|