J
Jim Carter
Hi experts,
I have the below issue:
I have an input table like this:
----- ---------- --------
Year Quarter Value
----- ---------- --------
2003 Q1 15.5
2003 Q1 7.5
2003 Q2 5.5
2003 Q4 10
2003 Q4 12.2
2003 Q2 11
2004 Q1 15.4
2004 Q2 17
2004 Q4 18
2004 Q3 12.5
2004 Q4 9.9
----------------------------------------------------
Now I want to populate the following combinations of year-quarter into
some variables ($a, $b, $c, $d etc) and summation calculations:
The combination should be in sequence (from youngest to oldest):
$a = concatenation of youngest combination (in this case, it is
2003-Q1).
$total1 = summation of all "Values" in the 2003-Q1 combination.
$b = concatenation of second youngest combination (in this case, it is
2003-Q2).
$total2 = summation of all "Values" in the 2003-Q2 combination.
$c = concatenation of third youngest combination (in this case, it is
2003-Q4).
$total3 = summation of all "Values" in the 2003-Q4 combination.
$d = concatenation of fourth youngest combination (in this case, it is
2004-Q1).
$total4 = summation of all "Values" in the 2004-Q1 combination.
$e = concatenation of fifth youngest combination (in this case, it is
2004-Q2).
$total4 = summation of all "Values" in the 2004-Q2 combination.
and so on....
Result should be :
$a = 2003-Q1
$value1 = 23
$b = 2003-Q2
$value2 = 16.5
$c = 2003-Q4
$value3 = 22.2
$d = 2004-Q1
$value4 = 15.4
$e = 2004-Q2
$value5 = 17
$f = 2004-Q3
$value6 = 12.5
$g = 2004-Q4
$value7 = 27.9
Can any one suggest a perl script to do this job? I am struggling with
the loops and arrays.
Thanks,
Jim
I have the below issue:
I have an input table like this:
----- ---------- --------
Year Quarter Value
----- ---------- --------
2003 Q1 15.5
2003 Q1 7.5
2003 Q2 5.5
2003 Q4 10
2003 Q4 12.2
2003 Q2 11
2004 Q1 15.4
2004 Q2 17
2004 Q4 18
2004 Q3 12.5
2004 Q4 9.9
----------------------------------------------------
Now I want to populate the following combinations of year-quarter into
some variables ($a, $b, $c, $d etc) and summation calculations:
The combination should be in sequence (from youngest to oldest):
$a = concatenation of youngest combination (in this case, it is
2003-Q1).
$total1 = summation of all "Values" in the 2003-Q1 combination.
$b = concatenation of second youngest combination (in this case, it is
2003-Q2).
$total2 = summation of all "Values" in the 2003-Q2 combination.
$c = concatenation of third youngest combination (in this case, it is
2003-Q4).
$total3 = summation of all "Values" in the 2003-Q4 combination.
$d = concatenation of fourth youngest combination (in this case, it is
2004-Q1).
$total4 = summation of all "Values" in the 2004-Q1 combination.
$e = concatenation of fifth youngest combination (in this case, it is
2004-Q2).
$total4 = summation of all "Values" in the 2004-Q2 combination.
and so on....
Result should be :
$a = 2003-Q1
$value1 = 23
$b = 2003-Q2
$value2 = 16.5
$c = 2003-Q4
$value3 = 22.2
$d = 2004-Q1
$value4 = 15.4
$e = 2004-Q2
$value5 = 17
$f = 2004-Q3
$value6 = 12.5
$g = 2004-Q4
$value7 = 27.9
Can any one suggest a perl script to do this job? I am struggling with
the loops and arrays.
Thanks,
Jim