Announcement

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

  • STATA with Panels

    Hello, I am trying to set a Panel with information from countries but I need to keep only those in which 2 of the variables have at least 6 observations each... Can someone help me?

  • #2
    Trinidad:
    welcome to this forum.
    No example of your data (as recommended by FAQ), poor replies.
    That said, you may want to try (caveat emptor: untested):
    Code:
    bysort panelid (year) var1 var2: keep if _N>=6
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you! I will be certain to use an example the next time. However, when I use the method proposed, all of the observations gets deleted. I want to declare a panel for countries in which I have more than 6 observations per PGD and "Democracy" I used this command, (the first bit is the panel, and the next are the variables I want to select)

      bysort numeric_country year fhpolrigaug lrgdpch: keep if _n>=6

      Code:
      use "/Users/trinidad/Desktop/Tarea 2 Econ/Income-and-Democracy-Data (1).dta"
      
      . browse
      
      
      *Pregunta 1*
      *hacer un panel de datos y quedarse con países con al menos 6 observaciones de PIB per cápita y democracia al mismo tiempo*
      
      
      *1 hay que usar encode para transfromar country (string) a una variable numérica*
      *para que no se de doble identificación hay que seleccionar aquellos países con  al menos 6 observaciones al mismo tiempo*
      
      encode country, generate (numeric_country)
       xtset numeric_country year
       list numeric_country year
       
       bysort numeric_country year fhpolrigaug lrgdpch: keep if _n>=6

      Comment


      • #4
        Trinidad:
        please note that queries concerning assignments/terms are not allowed on this forum (FAQ extra advice #4).
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X