Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Number of ID Variable in Panel Data

    Hi, I have a panel data (large n and small T) with -id- as the panel variable and -year- as the time variable. The year variable ranges from 2000-2003 and id captures the number of firms.

    The id variable is coded as follows:

    --id-- --year--
    1232 2000
    1232 2001
    1232 2002
    1232 2003

    1234 2000
    1234 2001
    1234 2002
    1234 2003

    When I summarise the dataset, minimum for id is 1 and max is 20,236. However, the id variable is not equally spaced so I cannot take 20,236 as the total number of firms in the data.

    I need to find the number of firms in the dataset based on the id variable. How to proceed?

  • #2
    Code:
    codebook id
    Or you can use the distinct command from SJ.

    Comment


    • #3
      Wouter Wakker: thanks, -distinct- command works.

      I used the following website:

      https://www.stata.com/support/faqs/d...-observations/

      Comment


      • #4
        Mohsin:
        another approach relies on -egen- -tag- function:
        Code:
        . use "http://www.stata-press.com/data/r15/nlswork.dta"
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        
        . egen flag=tag(idcode)
        
        . tab flag
        
        tag(idcode) |      Freq.     Percent        Cum.
        ------------+-----------------------------------
                  0 |     23,823       83.49       83.49
                  1 |      4,711       16.51      100.00
        ------------+-----------------------------------
              Total |     28,534      100.00
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo Lazzaro: Thanks.

          Comment

          Working...
          X