I have a panel data setting. I want to create another variable i.e. the standard deviation of investment from t-3 to t-1. In other words a new variable must compute the standard deviation of investment in past three years. please help.

My data looks as follows:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int unitid str18 firmid int time float Investment
1 "0876711D LN Equity" 2003           .
1 "0876711D LN Equity" 2004           .
1 "0876711D LN Equity" 2005           .
1 "0876711D LN Equity" 2006           .
1 "0876711D LN Equity" 2007           .
1 "0876711D LN Equity" 2008           .
1 "0876711D LN Equity" 2009   .04298013
1 "0876711D LN Equity" 2010 -.016369443
1 "0876711D LN Equity" 2011 -.012404328
1 "0876711D LN Equity" 2012  -.05723596
1 "0876711D LN Equity" 2013           .
1 "0876711D LN Equity" 2014           .
1 "0876711D LN Equity" 2015           .
1 "0876711D LN Equity" 2016           .
1 "0876711D LN Equity" 2017           .
1 "0876711D LN Equity" 2018           .
2 "1218069D LN Equity" 2003           .
2 "1218069D LN Equity" 2004    .4360955
2 "1218069D LN Equity" 2005   .26635048
2 "1218069D LN Equity" 2006   .23388498
2 "1218069D LN Equity" 2007   .21420796
2 "1218069D LN Equity" 2008    .2275067
2 "1218069D LN Equity" 2009   .16295853
2 "1218069D LN Equity" 2010   .11736838
2 "1218069D LN Equity" 2011    .0952867
2 "1218069D LN Equity" 2012           .
2 "1218069D LN Equity" 2013           .
2 "1218069D LN Equity" 2014           .
2 "1218069D LN Equity" 2015           .
2 "1218069D LN Equity" 2016           .
2 "1218069D LN Equity" 2017           .
2 "1218069D LN Equity" 2018           .
3 "1334987D LN Equity" 2003           .
3 "1334987D LN Equity" 2004  .005009345
3 "1334987D LN Equity" 2005  .016525032
3 "1334987D LN Equity" 2006  .009007737
3 "1334987D LN Equity" 2007 .0027638024
3 "1334987D LN Equity" 2008  .025354864
3 "1334987D LN Equity" 2009  .007856831
3 "1334987D LN Equity" 2010   .01920615
3 "1334987D LN Equity" 2011           .
3 "1334987D LN Equity" 2012           .
3 "1334987D LN Equity" 2013           .
3 "1334987D LN Equity" 2014           .
3 "1334987D LN Equity" 2015           .
3 "1334987D LN Equity" 2016           .
3 "1334987D LN Equity" 2017           .
3 "1334987D LN Equity" 2018           .
4 "1561649D LN Equity" 2003           .
4 "1561649D LN Equity" 2004    .2383473
4 "1561649D LN Equity" 2005   .23322147
4 "1561649D LN Equity" 2006    .2747023
4 "1561649D LN Equity" 2007           .
4 "1561649D LN Equity" 2008           .
4 "1561649D LN Equity" 2009   .16537003
4 "1561649D LN Equity" 2010    .4768854
4 "1561649D LN Equity" 2011   .14333837
4 "1561649D LN Equity" 2012   .13682278
4 "1561649D LN Equity" 2013   .11177154
4 "1561649D LN Equity" 2014    .2387057
4 "1561649D LN Equity" 2015           .
4 "1561649D LN Equity" 2016           .
4 "1561649D LN Equity" 2017           .
4 "1561649D LN Equity" 2018           .
5 "1638414D LN Equity" 2003           .
5 "1638414D LN Equity" 2004   .12095035
5 "1638414D LN Equity" 2005    .1120581
5 "1638414D LN Equity" 2006   .10006714
5 "1638414D LN Equity" 2007   .11736046
5 "1638414D LN Equity" 2008   -.1074682
5 "1638414D LN Equity" 2009   .10434808
5 "1638414D LN Equity" 2010    .0954181
5 "1638414D LN Equity" 2011   .14149284
5 "1638414D LN Equity" 2012   .28253892
5 "1638414D LN Equity" 2013   .15810315
5 "1638414D LN Equity" 2014   .03957232
5 "1638414D LN Equity" 2015           .
5 "1638414D LN Equity" 2016           .
5 "1638414D LN Equity" 2017           .
5 "1638414D LN Equity" 2018           .
6 "1655637D LN Equity" 2003           .
6 "1655637D LN Equity" 2004  .002285661
6 "1655637D LN Equity" 2005 .0007066662
6 "1655637D LN Equity" 2006 .0010206974
6 "1655637D LN Equity" 2007  .001707869
6 "1655637D LN Equity" 2008  .010133424
6 "1655637D LN Equity" 2009   .05300895
6 "1655637D LN Equity" 2010  .003342496
6 "1655637D LN Equity" 2011 .0040739654
6 "1655637D LN Equity" 2012 .0010755167
6 "1655637D LN Equity" 2013  .002353301
6 "1655637D LN Equity" 2014 .0014642834
6 "1655637D LN Equity" 2015  .003463925
6 "1655637D LN Equity" 2016   -.1074682
6 "1655637D LN Equity" 2017           .
6 "1655637D LN Equity" 2018           .
8 "3572335Q LN Equity" 2003           .
8 "3572335Q LN Equity" 2004   .09133787
8 "3572335Q LN Equity" 2005    .1582893
8 "3572335Q LN Equity" 2006   .18906696
end