全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
2237 8
2012-03-04
var1 var2 var3 var4
1       1        .       4
2      .         2        5

列求均值(或和)比较好求,现在我想行求均值(或和),但是注意考虑缺失值,即第一行的值为(1+1+4)/3等
即最后生成一列var5,它是前面按照上述要求的均值。
请问如何编程,谢谢了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-3-4 22:09:19
egen kk=rmean(var1 var2 var3 var4)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-5 06:55:36
蓝色 发表于 2012-3-4 22:09
egen kk=rmean(var1 var2 var3 var4)
谢谢蓝色,就是这个,前面这个r真好
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-5 11:41:58
hshly 发表于 2012-3-5 06:55
谢谢蓝色,就是这个,前面这个r真好
呵呵呵诃呵…  那个r真好…   那个r应该是row的意思…  很好… 很强大!!!!!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-5 12:52:17
h3327156 发表于 2012-3-5 11:41
呵呵呵诃呵…  那个r真好…   那个r应该是row的意思…  很好… 很强大!!!!!
是的
原来是写r
现在写全了row,不过原来的命令还是可以用的。

关键是egen的命令比较强大
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-5 12:52:48
rowfirst(varlist)
            may not be combined with by.  It gives the first nonmissing value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowlast(varlist)
            may not be combined with by.  It gives the last nonmissing value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowmax(varlist)
            may not be combined with by.  It gives the maximum value (ignoring missing values) in
            varlist for each observation (row).  If all values in varlist are missing for an
            observation, newvar is set to missing.

        rowmean(varlist)
            may not be combined with by.  It creates the (row) means of the variables in varlist,
            ignoring missing values; for example, if three variables are specified and, in some
            observations, one of the variables is missing, in those observations newvar will
            contain the mean of the two variables that do exist.  Other observations will contain
            the mean of all three variables.  Where none of the variables exist, newvar is set to
            missing.

        rowmedian(varlist)
            may not be combined with by.  It gives the (row) median of the variables in varlist,
            ignoring missing values.  If all variables in varlist are missing for an observation,
            newvar is set to missing in that observation.  Also see rowpctile().

        rowmin(varlist)
            may not be combined with by.  It gives the minimum value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowmiss(varlist)
            may not be combined with by.  It gives the number of missing values in varlist for
            each observation (row).

        rownonmiss(varlist) [, strok]
            may not be combined with by.  It gives the number of nonmissing values in varlist for
            each observation (row) -- this is the value used by rowmean() for the denominator in
            the mean calculation.

            String variables may not be specified unless the strok option is also specified.  If
            strok is specified, string variables will be counted as containing missing values
            when they contain "".  Numeric variables will be counted as containing missing when
            their value is ">.".

        rowpctile(varlist) [, p(#)]
            may not be combined with by.  It gives the #th percentile of the variables in
            varlist, ignoring missing values.  If all variables in varlist are missing for an
            observation, newvar is set to missing in that observation.  If p() is not specified,
            p(50) is assumed, meaning medians.  Also see rowmedian().

        rowsd(varlist)
            may not be combined with by.  It creates the (row) standard deviations of the
            variables in varlist, ignoring missing values.

        rowtotal(varlist) [, missing]
            may not be combined with by.  It creates the (row) sum of the variables in varlist,
            treating missing as 0.  If missing is specified and all values in varlist are missing
            for an observation, newvar is set to missing.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群