View previous topic :: View next topic
Author
Message
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
Is it possible to generate a percentage on a section break (trailer3) ?
Input columns:
department, actual amount, budget amount
sampe file:
010,0000010,0000012
020,0000020,0000021
030,0000030,0000035
Desired output:
Code:
department actual amount budgent amount variance percent
010 10 12 2 16.67
020 20 21 1 4.76
030 30 35 5 12.29
totals 68 8 11.76
Back to top
William Thompson Global Moderator Joined: 18 Nov 2006Posts: 3156 Location: Tucson AZ
What formula are you using for the percentage?
Have you looked at TRAILER3?
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
Yes, i have looked at trailer3.
The formula is (budget amount - actual amount) * 100 / variance.
variance = budget amount - actual amount.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You can do TOT, MIN, MAX and AVG in TRAILER3, but you can't do arithmetic. You can do arithmetic in BUILD (ADD, SUB, MUL, DIV, MOD). How about doing arithmetic in BUILD and adding extra fields with the results at the end of each record so you can use TOT in TRAILER3 for them?
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
jr3011 wrote:
Yes, i have looked at trailer3.
The formula is (budget amount - actual amount) * 100 / variance.
variance = budget amount - actual amount.
Jr3011,
You got the formula wrong based on the output you have shown. I think the right formula is
Code:
percentage = ((budget amount - actual amount) / budget amount) * 100
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
totaling on a percentage will not give the correct results.
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
I think either formual yeild the same results.
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
I guess i stumped you guys ?
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
jr3011,
The following JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
010,0000010,0000012
020,0000020,0000021
030,0000030,0000035
//OUT1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT2 DD DSN=&&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(20:C',',13,7,ZD,SUB,5,7,ZD,M11,LENGTH=7,C',',
(+10000,MUL,21,7,ZD),DIV,13,7,ZD,EDIT=(TT.TT))
OUTFIL FNAMES=OUT1,REMOVECC,
BUILD=(1:1,3,13:5,7,ZD,29:13,7,ZD,43:21,7,ZD,54:29,5,80:X),
HEADER1=('DEPARTMENT ACTUAL AMOUNT BUDGET',
' AMOUNT VARIANCE PERCENT',80:X),
TRAILER1=(80X)
OUTFIL FNAMES=OUT2,REMOVECC,NODETAIL,
TRAILER1=('TOTALS',29:TOT=(13,7,ZD,M10,LENGTH=7),
43:TOT=(21,7,ZD,M10,LENGTH=7),80:X)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&T1,DISP=SHR
// DD DSN=&&T2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,6,CH,EQ,C'TOTALS'),
OVERLAY=(54:(+10000,MUL,43,7,FS),DIV,29,7,FS,EDIT=(TT.TT)))
/*
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
jr3011 wrote:
I guess i stumped you guys ?
Jeez you couldn't wait for 45 mins ? wow We do have a regular job to attend
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
My apologies. Thanks alot for the help.
Back to top
Please enable JavaScript!