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

st: RE: ordering dates


From   "Steichen, Thomas J." <SteichT@rjrt.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: ordering dates
Date   Fri, 23 Sep 2005 14:19:56 -0400


Terra Curtis writes:

> I have a dataset like the sample shown below:
> 
> firm	patent	stageatsigning	date		awddate2	
> stagedummy
> .
> .
> .
> 285	4401756				12/01/96	
> 08/30/83	0
> 285	4401756				11/01/84	
> 08/30/83	0
> 285	4401756				01/01/93	
> 08/30/83	0
> 285	4401756				09/01/93	
> 08/30/83	0
> 285	4401756				08/01/94	
> 08/30/83	0
> 285	4401756				09/01/90	
> 08/30/83	0
> 285	4401756				04/01/96	
> 08/30/83	0
> 285	4401756				12/01/95	
> 08/30/83	0
> 285	4401756				10/01/96	
> 08/30/83	0
> 285	4401756				07/01/88	
> 08/30/83	0
> 285	4401756	Approved		12/01/92	
> 08/30/83	0
> 285	4401756	Discovery		02/01/92	
> 08/30/83	0
> 285	4401756	Discovery		02/01/95	
> 08/30/83	0
> 285	4401756	Discovery		01/01/86	
> 08/30/83	0
> 285	4401756	Discovery		01/01/96	
> 08/30/83	0
> 285	4401756	Formulation		08/01/95	
> 08/30/83	0
> 285	4401756	Lead Molecule	09/01/85	08/30/83	0
> 285	4401756	Lead Molecule	10/01/81	08/30/83	0*
> 285	4401756	Lead Molecule	04/01/83	08/30/83	0**
> 285	4401756	Lead Molecule	04/01/93	08/30/83	0
> 285	4401756	Lead Molecule	10/01/84	08/30/83	0
> 285	4401756	Phase I, Approved	01/01/92	
> 08/30/83	0
> 285	4401756	Phase II		12/01/93	
> 08/30/83	0
> 285	4401756	Preclinical		04/01/96	
> 08/30/83	0
> .
> .
> .
> 
> What I want to do is determine which 'stageatsigning' the 
> patent was in at the 'awddate2'  So, for this example, I want 
> to replace stagedummy=1 on the line marked with * since the 
> 'awddate2' is between the 'date' on that line
> and the date on the line marked **.   Any suggestions for how 
> I could do this?

* if date and awddate2 not in Stata date format, gen versions in Stata date format 
   gen date1=date(date,"md19y")
   format date1 %d
   gen awddate1=date(awddate2,"md19y")
   format awddate1 %d
* then
   bysort patent (date1): replace stagedummy=1 if date1< awddate1
   by patent: replace stagedummy = 0 if stagedummy[_n+1] == 1

* else if both date and awddate2 in Stata date format
   bysort patent (date): replace stagedummy=1 if date< awddate2
   by patent: replace stagedummy = 0 if stagedummy[_n+1] == 1

Tom


-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the
attorney-client or other legal privileges, and/or proprietary non-
public information. If you are not an intended recipient of this
message or an authorized assistant to an intended recipient, please
notify the sender by replying to this message and then delete it from
your system. Use, dissemination, distribution, or reproduction of this
message and/or any of its attachments (if any) by unintended recipients
is not authorized and may be unlawful.


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