sysuse auto,clear levelsof foreign ,local(levels) foreach x of local levels { di in yellow "`x' is a unique value of rep78" } //遍历各个变量的标签及变量值 sysuse auto.dta,clear local k=_N foreach var of varlist _all{ local a:var label `var' disp "`a'" forvalues i=1/`k'{ disp `var'[`i'] } } //遍历各个变量的标签 sysuse auto.dta,clear local k=_N foreach var of varlist _all{ local a:var label `var' disp "`a'" } //遍历各个变量名 sysuse auto.dta,clear local k=_N foreach var of varlist _all{ disp "`var'" } //遍历各个变量名 ds foreach v of varlist `r(varlist)' { dis "`v'" }
标签:disp,遍历,varlist,变量值,foreach,STATA,var,变量名,local From: https://www.cnblogs.com/xkdn/p/17328326.html