Announcement

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

  • first occurrence of a variable in a large dataset using by: egen first command

    Hi,

    I am just learning stata and have tried to read about this error online, but haven't had any luck. I am hoping someone here can help with might be a very basic question.

    I am trying to select the first instance of a program name to apply it to all existing records (let me know if you need more background information). This is what I have done:
    sort ProgramId
    by ProgramId: egen ProgName = first (UProgName)

    I'm using stata 12. It keeps telling me: unknown egen function first(). So I tried using firsttime instead of first. But it says the same thing: unknown egen function firsttime.

    I am tried reading about this and can't seem to figure out why it does not recognize the command. I have also tried using gen instead of egen, to not avail.

    I appreciate any help. Again, I'm learning, so I hope my question makes sense and look forward to your help.

    Thank you in advance for your help,
    Diana

  • #2
    The egen function first() is not part of official Stata but part of egenmore (SSC) which must be installed first.

    Code:
    ssc inst egenmore 
    Whether it does what you want I can't say. What does "first" mean for you? First in time, first in the dataset, or what?

    What led you to this code? Giving a precise URL or journal or book reference could clarify what you are doing. Similarly, a concrete example of your data using dataex (SSC) is usually helpful.

    FAQ Advice #12 and #13 at http://www.statalist.org/forums/help say more..

    Comment

    Working...
    X