View previous topic :: View next topic
|
Author |
Message |
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
I have the input file where avg time is extracted as:
Code: |
00000000000000.0562
00000000000000.0685
00000000000000.0783
00000000000000.0558
00000000000000.0759
00000000000000.1567
|
starting at position 44. This field is defined as Decimal 18,4 in database when it was extracted.
I need to take a average for the values in this column. How will i need to define this field in the EZT? Can anyone please help?
Thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
One way is to defne this as separate fields and then create a numeric field from the 2 pieces. The numeric field can then be summed / averaged. |
|
Back to top |
|
|
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
I think it will be a problem if there is any carry over from the values after decimal part. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
No, there won't if it is done properly. . .
You would combine the 2 pieces of each line into a single value with an implied decimal rather than the physical decimal currently in the data.
The re-constructed number would be 000000000000000562 with 4 implied decimal places (just like dollars and cents if this were a money field). In cobol, it would be 9(14)v9(4).
To repeat, there would be no problem with "carry over". |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
gprerna wrote: |
This field is defined as Decimal 18,4 in database when it was extracted. |
Or just extract it without editing in the decimal point....... |
|
Back to top |
|
|
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
Yeah...thats what actually i wanted to do, but was unable to extract without a decimal point from Dbase.
I used the below code in my extract parm:
Code: |
CHAR(COALESCE(AVE_TIME,0)),
|
But its extracting with a decimal point as shown above in the first post. Can you please suggest how to extract from Dbase in the below format?
Code: |
000000000000000562
000000000000000685
000000000000000783
000000000000000783
000000000000000783
|
Thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Do you really mean dbase? I've not seen dbase used for a long time.
You already have perfectly workable data. All you have to do is use it. . .
If you are unwilling to combine the 2 pieces with your code, you could always switch to cobol and use the numval funcation. . . . |
|
Back to top |
|
|
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
i want to do it using EZT...not COBOL |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If you had combined the fields as i mentioned hours ago, you would have completed the code before now. . .
Is there a problem with defining the first "field" (before the decimal) as
FIRST-HALF 14 N 0 and the second "field" as SECOND-HALF 4 N 4?
Keep in mind that you control the code and can define things as you need them. Just because the true value is "a field" that is no reason that you cannot deal with it in pieces to do what you need. . . |
|
Back to top |
|
|
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
I havent tried till now, but just thought that carry over might be a problem. I will try it once...thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
As i mentioned earlier - carry over will not be a problem so long as it is done correctly
After you get the code running and run a test, you might post that bit of the code back here if you'd like someone to review it with you |
|
Back to top |
|
|
gprerna
New User
Joined: 21 Mar 2007 Posts: 38 Location: US
|
|
|
|
ya sure...i will keep you posted |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Someone will be here. . .
I forgot to mention earlier, when defining the first and second "halves" of the number, but sure to leave one byte for the "." between the halves. It is a filler for this code. |
|
Back to top |
|
|
|