Page 1 of 1
Grouping and Count Records
Posted:
Fri Oct 19, 2012 1:00 am
by newjb
I know there has to be an easier way to do this.... I have a file that has say 200 records. Part of each record contains a form #. All I I want to group and summarize how many times each form occurs in those 200 records.
So for 200 records you would get something like this:
Form # # of Occurrences
12344 100
26351 10
85963 10
63693 2
98745 78
74582 100
Total number of records = 200
Thank You!!!!
Re: Grouping and Count Records
Posted:
Fri Oct 19, 2012 2:47 am
by NicC
It does make things much easier for people if you display your data/screen shots/code in the code tags. Click on the POSTREPLY button, not the QuickReply, and your will see the button for coding your data.
Re: Grouping and Count Records
Posted:
Fri Oct 19, 2012 3:15 am
by dick scherrer
Hello,
It looks like your sample counts are not correct. . .
As i mentioned previously, i don "do" Natural, but can you not define a summary report with the form number as the sequence/summary "key" and then count the entries by the form number?
Re: Grouping and Count Records
Posted:
Tue Oct 23, 2012 1:30 am
by RGZbrog
If you can guarantee that the number of records will remain small, and you do not require the results to be sorted, then try this:
DEFINE DATA LOCAL
1 #M (I4) CONST <20> /* Maximum number of forms
1 #TBL (0:#M)
2 #FORM (A5)
2 #COUNT (I4)
1 #WRK
2 #FORM (A5)
1 #E (I4)
1 #I (I4)
END-DEFINE
READ WORK 1 #WRK
EXAMINE #TBL.#FORM (0:#E) FOR #WRK.#FORM GIVING INDEX #I
IF #I = 0
THEN
ADD 1 TO #E
ASSIGN #I = #E
ASSIGN #TBL.#FORM (#I) = #WRK.#FORM
END-IF
ADD 1 TO #TBL.#COUNT (#I)
END-WORK
DISPLAY #TBL.#FORM (1:#E)
#TBL.#COUNT (1:#E)
END
Re: Grouping and Count Records
Posted:
Tue Oct 23, 2012 7:44 pm
by newjb
Thanks!!
Adabas, I got pulled away from this project and getting back on it today. I will let you know how I make out. Thank you for our help, this site is great!