全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
11474 1
2022-07-29

count是stata中用于计数的命令,但在egen里的用法略有不同,比较两个命令:



anycount(varlist), values(integer numlist) may not be combined with by.  It returns the number of variables in varlist for which values are equal to any integer value in a supplied numlist.  Values for any observations excluded by either if or in are set to 0 (not missing).  Also see anyvalue(varname) and anymatch(varlist).

count(exp)     (allows by varlist:)   creates a constant (within varlist) containing the number of nonmissing observations of exp.  Also see rownonmiss() and rowmiss().






二维码

扫码加我 拉你入群

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

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

全部回复
2022-7-30 18:19:08
之前想生成一个变量,等于某一个变量中出现某个值的次数,需要分类统计,用的是

复制代码


问题是只有 r==8那行有x的值,其他的行x是缺失

复制代码


所以又加了两行命令,就可以了。

试了下这种情况用count(r==8)和anycount都不太对。
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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