gen tz=0 local vv pid_a_c1 pid_a_c2 pid_a_c3 pid_a_c4 pid_a_c5 pid_a_c6 pid_a_c7 pid_a_c8 pid_a_c9 pid_a_c10 local k=_N forvalues i=1/`k'{ local mm=0 foreach var of varlist `vv'{ local mm=`mm'+1 if pid[`i']==`var'[`i'] { if `mm'==10{ local bza=ustrright("`var'",2) } else{ local bza=ustrright("`var'",1) } //disp `bza' if tb6_a18_c`bza'[`i']==1{ replace tz[`i']=tz[`i']+1 } } } }
标签:tz,STATA,mm,pid,循环,应用,var,bza,local From: https://www.cnblogs.com/xkdn/p/17367990.html