Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: RE : st: Question on data manipulation


From   "Andre pierre" <hcpats@hotmail.fr>
To   statalist@hsphsun2.harvard.edu
Subject   RE: RE : st: Question on data manipulation
Date   Fri, 21 Oct 2005 15:01:23 +0200

Thanks to Nick, Michael and Nicolas for your help.
Regards,
André
P.S: Nicolas, Your solution works perfectly, thanks!


From: "Nicolas Couderc" <Nicolas.Couderc@univ-paris1.fr>
Reply-To: statalist@hsphsun2.harvard.edu
To: <statalist@hsphsun2.harvard.edu>
Subject: RE : st: Question on data manipulation
Date: Fri, 21 Oct 2005 14:34:08 +0200

Hi,

I think that code will works. Probably not very efficient, but i hope it
will be useful. Let me know !

gen dummy=.
sort firm charac innov
replace dummy=(charac==charac[_n-1] & firm==firm[_n-1])
replace dummy=(charac==charac[_n+1] & firm==firm[_n+1]) if dummy!=1
bysort firm innov: egen dummy2=max(dummy)
drop dummy

HTH
Nicolas

------
Nicolas Couderc
TEAM-Finance
Maison des Sciences Economiques
Université de Paris I Panthéon-Sorbonne
106-112, boulevard de l'Hôpital
F-75647, Paris, Cedex 13

01 44 07 82 71
Email : couderc@univ-paris1.fr
Page web : http://team.univ-paris1.fr/teamperso/couderc/index.htm



-----Message d'origine-----
De : owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] De la part de Andre pierre
Envoyé : vendredi 21 octobre 2005 13:32
À : statalist@hsphsun2.harvard.edu
Objet : Re: st: Question on data manipulation


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.

Regards,
André


>From: Susanne und Ulrich Kohler <suli.kohler@web.de>
>Reply-To: statalist@hsphsun2.harvard.edu
>To: statalist@hsphsun2.harvard.edu
>Subject: Re: st: Question on data manipulation
>Date: Fri, 21 Oct 2005 13:15:14 +0200
>
>On Friday 21 October 2005 11:48, Andre pierre wrote:
> > I have a question, for which the answer might be simple, but I did
> > not
>find
> > it yet.
> > 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]
>
>--
>kohler@wz-berlin.de
>+49 (0)30 25491-361
>*
>* 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/

_________________________________________________________________
MSN Hotmail : antivirus et antispam gratuits !
http://www.imagine-msn.com/hotmail/default.aspx?locale=fr-FR

*
* 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/

--
Ce message a été vérifié par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.


--
Ce message a été vérifié par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.


*
* 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/
_________________________________________________________________
2 Go de stockage avec MSN Hotmail Plus ! http://join2.msn.com/?pgmarket=fr-fr&page=hotmail/es2&DI=81&XAPID=3940&SU=&HL=hpleftslot

*
* 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/




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index