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: Panel data construction


From   Michael Barker <[email protected]>
To   [email protected]
Subject   Re: st: Panel data construction
Date   Wed, 31 Jul 2013 09:36:03 -0400

You could use egen commands with by:

sort Country Year
by Country Year: egen num_firms = count(Ownership)
by Country Year: egen num_foreign = total(Ownership)

gen ratio = num_foreign / num_firms
drop num_foreign num_firms

Are there any missing values for ownership? If so, check the help file
to understand how total() treats missing values.

Mike




On Wed, Jul 31, 2013 at 7:28 AM, Marcello Pagano
<[email protected]> wrote:
> Posting this for Sotiris:
>
>
> -------- Original Message --------
>
> I have the following dataset :
> Firm Year Country Ownership
> A 1997 USA 0
> A 1998 USA 1
> A 1999 USA 1
> B 1997 USA 0
> B 1998 USA 0
> B 1999 USA 1
> C 1998 CAN 0
> C 1999 CAN 0
> ......
> this is a panel data that consits from many countries and 12,000 different
> firms. The ownership variable is dummy with 1=foreign owned and 0=domestic
> owned. The firm variable is string.
>
> I want to create the ratio=(number of banks that are foreign owned by year
> and country)/(total number of banks by year and country). In my previous
> example the ratio sould look like this:
> Firm Year Country Ownership ratio
> A 1997 USA 0 (0/2)=0
> A 1998 USA 1 (1/2)=0.5
> A 1999 USA 1 (2/2)=1
> B 1997 USA 0 (0/2)=0
> B 1998 USA 0 (1/2)=0.5
> B 1999 USA 1 (2/2)=1
> C 1998 CAN 0
> C 1999 CAN 0
>
> Thank you in advance.
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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