stata 判断字符型变量的个数及变量名

use cgss\cgss2015,clear
local ci=0
local cc ""
foreach v of varlist _all{
    cap confirm string variable `v'
    if !_rc{
        local ci=`ci'+1
        local cc="`cc'"+" "+"`v'"
        disp "`v'"
    }
}
disp `ci'
disp "`cc'"

 

posted @ 2023-04-19 08:07  myrj  阅读(372)  评论(0编辑  收藏  举报