公卫百科  > 所属分类  >  Stata   
[0] 评论[0] 编辑

countmatch

countmatch counts observations for which each distinct value of var1 is  matched by (is equal to) var2, whether for the same observation or for  some different observation(s).

公卫论坛

var1 and var2 should be both numeric or both string.
. input id1 id2 

id1        id2
1. 1    5     
2. 2    6
3. 3    7

公卫百科


4. 4    8 
5. 5    9 
6. end

.
. countmatch id1 id2, gen(count)

. list


   id1   id2   count
-
1.    1     5       0

公卫家园


2.    2     6       0
3.    3     7       0
4.    4     8       0 公卫百科
5.    5     9       1


. gen indicator = count > 0

.
. list

   
    id1   id2   count   indica~r   
公卫考场

   
1.    1     5       0          0   
2.    2     6       0          0   

公卫考场


3.    3     7       0          0   
4.    4     8       0          0    公卫论坛
5.    5     9       1          1   
   

.
end of do-file

.


公卫家园

附件列表


0

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

如果您认为本词条还有待完善,请 编辑

上一篇 rangestat    下一篇 留守儿童

标签

暂无标签

参考资料

[1].  Identifying if an observation in one variable appears in another variable   https://www.statalist.org/forums/forum/general-stata-discussion/general/1385325-identifying-if-an-observation-in-one-variable-appears-in-another-variable

同义词

暂无同义词