The following may help here:
4/05 How do I create variables summarizing for each
individual properties of the other members of a
group?
http://www.stata.com/support/faqs/data/members.html
2/03 How do I create a variable recording whether any
members of a group (or all members of a group)
possess some characteristic?
http://www.stata.com/support/faqs/data/anyall.html
Nick
n.j.cox@durham.ac.uk
Andre pierre
> Thanks, but this does not work: The "dummy" variable contains
> only "ones". I
> had already tried with with the "by:" command, but I am not
> sure about how to use it.
Ulrich Kohler replied to Andre pierre
> > > I am working on a datset that contains information on
> innovating firms.
> >My
> > > question might be more understandable with the following example:
> > > Firm 1 has 3 innovations (A, B and C). A and B have one
> caracteristic in
> > > common (x); B and C have another caracteristic in common
> (g), while
> > > Innovation D does not have the same caracteristic as any
> of the other
> > > innovations.
> > > I would like to create a dummy that takes the value one
> if an invention
> >by
> > > a given firm has at least one caracteristic in common
> with one of the
> >other
> > > innovations by the the same firm. My question is how can
> I get this
> >dummy?
> > >
> > > Firm; innovation; carateristic; dummy
> > > 1; A; x; 1
> > > 1; A; y; 1
> > > 1; A; z; 1
> > > 1; B; x; 1
> > > 1; B; g; 1
> > > 1; C; g; 1
> > > 1; D; f; 0
> >
> >. by firm (charateristic): gen dummy = _N > 0
> >. by firm innovation (dummy): replace dummy = dummy[_N]
*
* 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/