I don't understand all this. You make various
statements that are not substantiated. Nor
can I comment on code you don't show us or
reports that things did not work.
Also, -egen, group()- doesn't work from the bottom
to the top. It assigns labels according to
sort order of the variable lists. This is
explained in the help.
How to respect the current order of observations
was explained in my last email.
Nick
[email protected]
Ana Gabriela Guerrero Serdan
> Yes, I included only the ones that died. I have more
> than 50,000 observations, I didnt list them all here
> but I cannot use tab, so its also difficult to
> generate a variable and replace, I assume to have
> thousands of events.
>
>
> I have tried already using the egen function. But
> since I have mix non-numericals and numbers for each
> type of incident it somehow doesnt count the number of
> events.
>
>
> But I will look into the ssc distinct events.
>
> Doing what you suggested gives me the following:
> . egen event = group(incident)
>
> . list count incident event
>
> +--------------------------+
> | count incident event |
> |--------------------------|
> 1. | 1 x007 5145 |
> 2. | 2 x038 5175 |
> 3. | 3 x038 5175 |
> 4. | 4 x038 5175 |
> 5. | 5 x038 5175 |
> |--------------------------|
> 6. | 6 x038 5175 |
> 7. | 7 x038 5175 |
> 8. | 8 x038 5175 |
> 9. | 9 x038 5175 |
> 10. | 10 x038 5175 |
> |--------------------------|
> 11. | 11 x038 5175 |
> 12. | 12 x038 5175 |
> 13. | 13 x038 5175 |
> 14. | 14 x038 5175 |
> 15. | 15 x038 5175 |
>
> I does assign a different number to each event but it
> does it from the botton to top.
> --- n j cox <[email protected]> wrote:
>
> > I can't see details on died or not died here.
> > I guess everybody in the dataset died.
> >
> > On one question, you want the number of distinct
> > incidents.
> > This is given by
> >
> > tab incident
> > di r(r)
> >
> > or by
> >
> > ssc inst distinct
> > distinct incident
> >
> > See also
> > How do I compute the number of distinct
> > observations?
> > http://www.stata.com/support/faqs/data/distinct.html
> >
> > On another question, you want to label distinct
> > incidents, 1 up.
> >
> > This is
> >
> > egen event = group(incident)
> >
> > See also
> > How do I create individual identifiers numbered from
> > 1 upwards?
> > http://www.stata.com/support/faqs/data/group.html
> >
> > In short, the FAQs are friendly answers to your
> > questions.
> >
> > (Incidentally, for me,
> >
> > sort incident count
> > by incident : gen event = _n
> >
> > does not do what you report.)
> >
> > Nick
> > [email protected]
> >
> > Ana Gabriela Guerrero Serdan
> >
> > I am struggling on the following. I need to count
> > the
> > events or number of incidents where people died. I
> > have information at the individual level such as:
> >
> > +----------------------------+
> > | count incident sex |
> > |----------------------------|
> > 1. | 1 x007 unknown |
> > 2. | 2 x038 male |
> > 3. | 3 x038 male |
> > 4. | 4 x038 male |
> > 5. | 5 k000 female |
> > |----------------------------|
> > 6. | 6 k000 unknown |
> > 7. | 7 x038 unknown |
> > 8. | 8 x038 unknown |
> > 9. | 9 x035 unknown |
> > 10. | 10 x040 unknown |
> >
> > I am trying to generate a new variable call "event"
> > that will put a number to each same incident
> >
> > like: incident x007 event 1
> > incident x038 event 2
> > incident k000 event 3
> > etc..
> >
> > I tried using:
> >
> > sort incident count
> > by incident: gen event = _n
> >
> > but it gives only values to 1 to the first event and
> > 0
> > to the rest.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/