Announcement

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

  • Drop variable if less

    Hi,

    I am going to drop firms that have less than 5 workers. Variables: Firms' ID=NPC_FIC & nationality of workers: national.
    Any help appreciated.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double NPC_FIC long national
    500000002 153
    500000002 153
    500000002 153
    500000002 153
    500000002 153
    500000033 153
    500000033 153
    500000050 153
    500000050 153
    500000083 153
    500000104 189
    500000104 153
    500000119 153
    500000119 153
    500000119 153
    500000119 153
    500000119 153
    500000119 153
    500000119 153
    500000119 153
    500000121 153
    500000121 153
    500000157 153
    500000157 153
    500000157 153
    500000165 153
    500000165 153
    500000165 153
    500000180 153
    500000198 153
    500000198 153
    500000198 153
    500000201 153
    500000204 153
    500000204 153
    500000212 153
    500000215 153
    500000215 153
    500000215 153
    500000215 153
    500000240 153
    500000240 153
    500000276 153
    500000279 153
    500000284 153
    500000284 153
    500000284 153
    500000284 153
    500000305 153
    500000324  58
    500000334 153
    500000341 153
    500000341 153
    500000346  63
    500000346 153
    500000346 153
    500000346  28
    500000346 153
    500000376 153
    500000376 153
    500000395 153
    500000395 153
    500000395 153
    500000395 153
    500000395 153
    500000395 153
    500000465 153
    500000465 153
    500000465 153
    500000470 153
    500000470 153
    500000478 153
    500000543 153
    500000543 153
    500000565 153
    500000583 153
    500000633 153
    500000633 153
    500000675 153
    500000709 153
    500000748 153
    500000757 153
    500000765 153
    500000765 153
    500000765 153
    500000766 153
    500000766 153
    500000774 153
    500000791 153
    500000791 153
    500000796 153
    500000846 153
    500000856 153
    500000856 153
    500000856 153
    500000856 153
    500000856 153
    500000856 153
    500000856 153
    500000856 153
    end
    label values national nacio1
    label def nacio1 28 "BR", modify
    label def nacio1 58 "ES", modify
    label def nacio1 63 "FR", modify
    label def nacio1 153 "PT", modify
    label def nacio1 189 "UA", modify
    Listed 100 out of 2536961 observations

  • #2
    On the assumption that each observation in the data set represents a different worker:
    Code:
    by NPC_FIC, sort: drop if _N < 5

    Comment


    • #3
      Prof Schechter,
      Much appreciated.

      Comment


      • #4
        For a tutorial on by: see the paper identified by

        Code:
        search pr0004, entry

        Comment

        Working...
        X