STATA 判断一个变量是不是都是缺失值,如果是则删除该变量

use e:\statashu\bobo\zhu,clear
local cc 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 c=_N
foreach var of varlist `cc'{
    local cx=0
    forvalues i=1/`c'{
        if(missing(`var'[`i'])){
            local cx=`cx'+1
            
        }
    }
    disp `cx'
    if(`cx'==_N){
        drop `var'
    }
}
 

 

posted @ 2023-06-12 11:09  myrj  阅读(161)  评论(0编辑  收藏  举报