Hello,
I am trying to calculate the difference between the values of different rows for the same variable and sum the differences. Here is how my data looks like:
no | sic | year | advertising ($) | sum of the differences
1 | 100 | 2000 | 10 | a = abs(10-11) + abs(10-12) + abs(10-13) + abs(10-14)
2 | 100 | 2000 |11 | b = abs(11-10) + abs(11-12) + abs(11-13) + abs(11-14)
3 | 100 | 2000 |12 | c = abs(12-10) + abs(12-11) + abs(12-13) + abs(12-14)
4 | 100 | 2000 |13 | d = abs(13-10) + abs(13-11) + abs(13-12) + abs(13-14)
5 | 100 | 2000 |14 | e = abs(14-10) + abs(14-11) + abs(14-12) + abs(14-13)
What I like to do is to calculate a,b,c,d, and e the way I showed. I need this for a big dataset. How can I code this? Thanks for helping me out.
I am trying to calculate the difference between the values of different rows for the same variable and sum the differences. Here is how my data looks like:
no | sic | year | advertising ($) | sum of the differences
1 | 100 | 2000 | 10 | a = abs(10-11) + abs(10-12) + abs(10-13) + abs(10-14)
2 | 100 | 2000 |11 | b = abs(11-10) + abs(11-12) + abs(11-13) + abs(11-14)
3 | 100 | 2000 |12 | c = abs(12-10) + abs(12-11) + abs(12-13) + abs(12-14)
4 | 100 | 2000 |13 | d = abs(13-10) + abs(13-11) + abs(13-12) + abs(13-14)
5 | 100 | 2000 |14 | e = abs(14-10) + abs(14-11) + abs(14-12) + abs(14-13)
What I like to do is to calculate a,b,c,d, and e the way I showed. I need this for a big dataset. How can I code this? Thanks for helping me out.
Comment