Hi guys.
I have two data sets that looks like this:
data a;
input month monthly_sum sum1 sum2 sum3 sum4 sum5;
cards;
1 10 1 1 1 1 1
2 20 2 2 2 2 .
3 30 3 3 3 . .
4 40 4 4 . . .
5 50 5 . . . .
6 60 . . . . .
;
data b;
input month monthly_sum total1 total2 total3 total4 total5;
cards;
1 100 10 10 10 10 10
2 200 20 20 20 20 .
3 300 30 30 30 . .
4 400 40 40 . . .
5 500 50 . . . .
6 600 . . . . .
;
What I want to do is create a new dataset that divides all the cells for sum1-sum5 for every row from dataset a with the "same location" cells for total1-total5 from dataset b.
The result should look like this:
data result;
input month monthly_sum calc1 calc2 calc3 calc4 calc5;
cards;
1 10 0.1 0.1 0.1 0.1 0.1
2 20 0.1 0.1 0.1 0.1 .
3 30 0.1 0.1 0.1 . .
4 40 0.1 0.1 . . .
5 50 0.1 . . . .
6 60 . . . . .
;
For example:
first row (month=1) : dataset a.sum1/dataset b.total1 = 1/10 = 0.1
first row (month=1) : dataset a.sum2/dataset b.total2 = 1/10 = 0.1...etc
second row (month=2) : dataset a.sum1/dataset b.total1 = 2/20 = 0.1
second row (month=2) : dataset a.sum2/dataset b.month2 = 2/20 = 0.1 ...etc
.
.
etc
I guees arrays would be perfect for this, but how do you use arrays when there's two datasets involved?
Do you have any ideas ? : )