Grouping and Count Records



Software AG's platform-independent programming language with full support for open-source and Internet applications

Grouping and Count Records

Postby newjb » Fri Oct 19, 2012 1:00 am

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!!!!
newjb
 
Posts: 20
Joined: Fri Sep 07, 2012 11:25 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Grouping and Count Records

Postby NicC » Fri Oct 19, 2012 2:47 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Grouping and Count Records

Postby dick scherrer » Fri Oct 19, 2012 3:15 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Grouping and Count Records

Postby RGZbrog » Tue Oct 23, 2012 1:30 am

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
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: Grouping and Count Records

Postby newjb » Tue Oct 23, 2012 7:44 pm

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!
newjb
 
Posts: 20
Joined: Fri Sep 07, 2012 11:25 pm
Has thanked: 3 times
Been thanked: 0 time


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post