The dataset is the following:
ID | communityID | treat |
1 | 1 | 1 |
2 | 1 | 1 |
3 | 1 | 0 |
4 | 1 | 1 |
5 | 2 | 0 |
6 | 2 | 1 |
preserve
contract communityID treat, zero nomiss
drop if treat==0 // IN ORDER TO HAVE m:1 MERGE
save treat.dta, replace
restore
merge m:1 communityID using treat.dta
contract communityID treat, zero nomiss
drop if treat==0 // IN ORDER TO HAVE m:1 MERGE
save treat.dta, replace
restore
merge m:1 communityID using treat.dta
communityID | treat | _freq |
1 | 1 | 3 |
1 | 0 | 1 |
2 | 1 | 1 |
2 | 0 | 1 |
0 Response to Count frequencies of (binary) variable and merge these to original dataset
Post a Comment