Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to count countries by year


From   Chris Parker <[email protected]>
To   [email protected]
Subject   Re: st: How to count countries by year
Date   Fri, 4 Mar 2011 10:37:30 +0000

Hi Emanuele,

Assuming you have one observation per year per state you should be
able to do the following

bysort year: gen numcountry=_N

Chris

Chris Parker

________________________________

PhD Candidate | Management Science & Operations
London Business School | Regent's Park | London NW1 4SA | United Kingdom
Direct line +44 (0)20 7000 8816 | Email [email protected]

On Fri, Mar 4, 2011 at 10:28 AM, emanuele mazzini
<[email protected]> wrote:
>
> Hi there.
> I occurred in a little problem in counting the observations of my
> dataset. I have panel data and need to count how many countries are
> there for each year. I tried with the following command (assuming that
> cty1 is the name of each country):
>
> bys year: count if  cty1[_n]!= cty1[_n-1]
>
> but Stata gives a result which is not what I was expecting.
> Can anybody help?
> Thank you everyone in advance,
> Emanuele Mazzini.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
> ______________________________________________________________________
>
> This email has been scanned by the MessageLabs Email Security System
> on behalf of the London Business School community.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index