蓝色 发表于 2018-4-22 20:56 
https://bbs.pinggu.org/thread-6340844-1-1.html
我的数据是从1998-2016年,30个省份,以GDP变量为例,你看看我的命令对不对。另外,input命令中,每个GDP后面都要有年份数字,有18个年份,有没有简介的语句代替?
set more off
input long(ID GDP2016 GDP2015 GDP2014 GDP2013 GDP2012 GDP2011 GDP2010 GDP2009 GDP2008 GDP2007 GDP2006 GDP2005 GDP2004 GDP2003 GDP2002 GDP2001 GDP2000 GDP1999 GDP1998)
(excel数据,如图所示)
reshape long GDP, i(ID) j(year)
gen provice="省份" ///生成省份名称变量
replace provice="北京" if ID=11 ///对每个省份名称变量赋值
replace provice="天津" if ID=12
replace provice="河北" if ID=13
replace provice="山西" if ID=14
replace provice="内蒙古" if ID=15
(///后面省份命令同上,省略)
end