Hello all,
I'm trying to randomly delete three observations for each group, and add the result as a new column. Does anyone know how to randomly delete three observations by group?
The dataset I have is like the following:
ID year prep
1 2000 550
1 2001 600
1 2002 580
1 2003 550
1 2004 570
... ... ...
1 2018 550
2 2000 600
2 2001 600
2 2002 580
2 2003 550
2 2004 570
... ... ...
and I'm trying to get the new dataset as:
ID year prep new
1 2000 550 550
1 2001 600 .
1 2002 580 580
1 2003 550 .
1 2004 570 570
1 2005 530 530
1 2006 545 .
... ... ... ...
1 2018 550 550
2 2000 600 600
2 2001 600 .
2 2002 580 .
2 2003 550 550
2 2004 570 570
... ... ... ...
Thank you all!
Best,
Hua
... View more