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/