- * Example generated by -dataex-. To install: ssc install dataex
- clear
- input str4 hhid float(year consump)
- "001" 2015 900
- "001" 2017 1200
- "001" 2019 850
- "003" 2015 977
- "003" 2017 1022
- "003" 2019 1111
- "005" 2017 1223
- "005" 2019 1300
- "008" 2015 998
- "008" 2017 765
- "009" 2017 999
- "010" 2019 1033
- end
所以我需要的是生成变量consump_lag,如001样本中,2019期的consump_lag对应的是2017期的consump数据。请问各位老师同学应使用什么命令?
Ps. 自己有使用gen consump_lag1 = l.consump这条命令,但报错 not sorted r(5);