I have a data frame of daily data like this
date firms value ID
6/4/2007 A 16 1
6/5/2007 A 18 1
6/20/2007 A 22 2
6/29/2007 A 25 2
6/21/2007 A 12 3
6/4/2007 B 14 1
6/5/2007 B 19 2
6/20/2007 B 17 2
6/29/2007 B 12 1
6/21/2007 B 10 3
Now I want to get the ID wise sum of each day of that value. Since it is a panel data, the sum value will repeat in repeated date. The expected value output is like this:
date firms value ID ID 1 Sum ID 2 Sum ID 3 Sum
6/4/2007 A 16 1 30 0 0
6/5/2007 A 18 1 18 19 0
6/20/2007 A 22 2 0 39 0
6/29/2007 A 25 2 12 25 0
6/21/2007 A 12 3 0 0 22
6/4/2007 B 14 1 30 0 0
6/5/2007 B 19 2 18 19 0
6/20/2007 B 17 2 0 39 0
6/29/2007 B 12 1 12 25 0
6/21/2007 B 10 3 0 0 22
Please help me in this regard. I could not find the code from internet.