[软体程式类别]:
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://webptt.com/cn.aspx?n=bbs/Statistics/M.1612922433.A.514.html
※ 编辑: evilove (69.140.102.182 美国), 02/10/2021 10:25:50