[程式] Stata scalar 問題

看板Statistics作者時間4年前 (2021/02/10 10:00), 4年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
[軟體程式類別]: Stata [程式問題]: 如何使用 scalar [軟體熟悉度]: 熟悉 [問題敘述]: 想要把一個變項的平均數(var_mean) pass給另外一個指令使用 但不曉得怎麼寫 dis var_mean 有看到 .9454545 但往下就fail了 [程式範例]: . local bi_var alzunit anymdex anyunit hospbase multifac profit . foreach v of varlist `bi_var' { 2. quietly summ `v' 3. scalar define var_mean = r(mean) 4. dis var_mean 5. prtest `v' = var_mean if interested == 1 6. } .09454545 var_mean is not a 0/1 variable r(450); 另一個寫法 . local bi_var alzunit anymdex anyunit hospbase multifac profit . foreach v of varlist `bi_var' { 2. tempvar var_mean 3. egen `var_mean' = mean(`v') 4. dis `var_mean' 5. prtest `v' = `var_mean' if interested == 1 6. } .09454545 __000000 is not a 0/1 variable r(450); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 69.140.102.182 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1612922433.A.514.html ※ 編輯: evilove (69.140.102.182 美國), 02/10/2021 10:25:50
文章代碼(AID): #1W8pv1KK (Statistics)
文章代碼(AID): #1W8pv1KK (Statistics)