Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: tabulate or other command?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: tabulate or other command?
Date   Mon, 19 Nov 2007 14:28:11 -0000

This is an FAQ.

How do I compute the number of distinct observations? 
http://www.stata.com/support/faqs/data/distinct.html 

e.g. 

bysort postcode id: gen nvals = _n == 1
by postcode : replace nvals = sum(nvals) 
tabdisp postcode, cell(nvals) 

Nick
[email protected]

[email protected]
--------------------
The idea is to calculate the total person for each code.
For ex
id postcode region
1   1        2
1   1        2
1   2        2
1   3        2
2   1        4
3   1        5


So I have 3 people in postcode1 1 in postcode 3 and 1 in postcode2.
if use tab the result is 4 obs with post code 1, but I have only 3
people, so because id is not unique.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index