|
View previous topic :: View next topic
|
| Author |
Message |
socker_dad
Active User

Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
G'Day Gents and Ladies!
I've got a file that contains a field that repeats 10 times. The value for which I am searching can appear in any, several, or none of those 10 positions.
I'm trying to count the total number of records in which the value appears and have experienced some problems. I'd just do it in interactive mode, but with over 50 million records, I just don't want to sit here all day!
This code gives me an individual total for each position (edited for brevity's sake):
| Code: |
$$DD01 TALLY IF=(55,EQ,T'B-636.3-B'),
ACCUM=(582,1,C,'RECORD COUNT'),
IF=(107,EQ,T'B-636.3-B'),
ACCUM=(582,1,C,'RECORD COUNT')
|
Then I manually add the 10 results together. Yeah, it works, but I know there has to be a better way.
I've tried all 10 IF's with a single ACCUM, but realized that it then requires all IF's to be true before accumulating. Seizing on that discovery, I tried ORIF's with just the first two columns:
| Code: |
$$DD01 TALLY IF=(055,EQ,T'B-636.3-B'),
ORIF=(107,EQ,T'B-636.3-B'),
ACCUM=(582,1,C,'RECORD COUNT')
|
This just gave me the total for the second column, not the first. Inserting a second ACCUM statement between the IF's just gave me the individual totals again.
So what am I missing? |
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Why not follow the File Aid Batch Reference Manual examples and code it as
| Code: |
$$DD01 TALLY IF=(055,EQ,T'B-636.3-B',
107,EQ,T'B-636.3-B'),
ACCUM=(582,1,C,'RECORD COUNT')
|
|
|
| Back to top |
|
 |
socker_dad
Active User

Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
Well, I'm referring to File Aid Batch Reference Manual Release 9.2 and I don't see an example like that. However, I gave it a whirl and got this:
| Code: |
$$DD01 TALLY IF=(055,EQ,T'B-636.3-B',
107,EQ,T'B-636.3-B',
159,EQ,T'B-636.3-B',
211,EQ,T'B-636.3-B',
263,EQ,T'B-636.3-B',
315,EQ,T'B-636.3-B',
367,EQ,T'B-636.3-B',
419,EQ,T'B-636.3-B',
471,EQ,T'B-636.3-B',
523,EQ,T'B-636.3-B'),
ACCUM=(582,1,C,'RECORD COUNT B-636.3-B')
F I L E - A I D V9.3.1 FEB - 12 - 2013 10.01.43 *ACCUM TOTALS LIST*
FOLLOWING TOTALS DEVELOPED FROM
AT.REW.#030.MAC60560.CMPOSITE.FUTR.G0001V00 VOL=TST002
RECORD COUNT B-636.3-B--------------------------------------------0
|
The problem is, totalling by each column and manually adding up the column totals gives me:
| Code: |
COL 01 B-636.3-B------------------------------------------------262
COL 02 B-636.3-B------------------------------------------------388
COL 03 B-636.3-B------------------------------------------------232
COL 04 B-636.3-B-------------------------------------------------71
COL 05 B-636.3-B-------------------------------------------------45
COL 06 B-636.3-B-------------------------------------------------13
COL 07 B-636.3-B--------------------------------------------------4
COL 08 B-636.3-B--------------------------------------------------0
COL 09 B-636.3-B--------------------------------------------------0
COL 10 B-636.3-B--------------------------------------------------0 |
|
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
The latest version of the Batch Reference manual I have is 9.1, which includes section 4.26.1, which has
| Quote: |
Example2:
$$DD01 PRINT IF=(1,EQ,C'A',17,EQ,C'1,2,3')
$$DD01 PRINT IF=(1,EQ,C'A',17,EQ,C'1',17,EQ,C'2',17,EQ,C'3')
Example 2 shows two types of coding to print records that contain the character A in location 1, OR have the character 1, 2, or3 in location 17. |
and I tested with
| Code: |
$$DD01 TALLY IF=(055,EQ,T'B-636.3-B',
070,EQ,T'B-636.3-B',
085,EQ,T'B-636.3-B',
100,EQ,T'B-636.3-B'),
ACCUM=(1,1,C,'RECORDS') |
and 15 records in the file -- 5 blanks ones and 1 matching column 55, 2 matching 70, 3 matching 85, and 4 matching 100. My results are
| Code: |
RECORDS----------------------------------------------------------10
|
|
|
| Back to top |
|
 |
socker_dad
Active User

Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
Sweet - I used your example and got the right answer.
I wonder why they changed the manual......oh crap - they didn't.
And it's still 4.26.1. Boy, do I feel dumb now. |
|
| Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
| LOL -- at least you got the right answer! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|