Hello,

I am currently trying to transform a panel data into a cross-section.
I have something like this :

ID_number Year Give money to charity (give) Has given in 2012 (giv12)
ID1 2012 0 0
ID1 2014 0 0
ID1 2016 1 0
ID1 2018 1 0
ID2 2012 1 1
ID2 2014 0 1
ID2 2016 1 1
ID2 2018 1 1
ID3 2012 1 1
ID3 2014 1 1
ID3 2016 0 1
For now I have just generated the column giv12 (has given in 2012) with only 0.
I have tried this code :
by ID_number: replace give12 = 1 if give==1 & Date==2012, but it only replace for the row and not for every rows belong to the ID.


Thank you for your help !