Yu等人2018年发在smj上的文章UNDERPERFORMANCE DURATION AND INNOVATIVE SEARCH: EVIDENCE FROM THE HIGH-TECH MANUFACTURING INDUSTRY的一个变量
Underperformance duration at time t-1: A firm was coded as “0” if its performance was above or equal to aspiration and the length of the underperforming period was used for underperforming firms. For example, a firm would be coded as 1 if it had been underperforming for 1 year, 2 if it had been underperforming for 2 consecutive years, etc.
这里的aspiration是和行业中位数的比较。
请问这个变量是否可以通过stata编码,代码怎么写?(难点在于如何识别【连续】n年低于行业中值)
谢谢!
//生成变量“绩效连续n年低于行业平均水平want”
//企业firm 年year(假设5年)某年某企业是否低于行业平均水平 temp(哑变量)
//定义面板数据
xtset firm year
//生成是否连续n年低于行业平均变量的哑变量
gen a=temp*l.temp
gen b=l2.temp*a
gen c=l3.temp*b
gen d=l4.temp*c
//生成最终连续变量want并不断replace
gen want=1 if temp==1
replace want=2 if a==1
replace want=3 if b==1
replace want=4 if c==1
replace want=5 if d==1
replace want=0 if want==.