Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: resend


From   "Lachenbruch, Peter" <[email protected]>
To   <[email protected]>
Subject   RE: st: resend
Date   Fri, 14 Nov 2008 08:43:43 -0800

This works perfectly. Thanks.  I hadn't noticed that a few of my dates
had 2 digit years.  I had some dates that were patient ids and that
overshadowed the other issue.  Oh well, now I get to demonstrate to
myself my inadequacies as a data manager...

ON my soapbox:  for those of you who are starting to manage data, the
solid advice that has appeared on this list from Svend Juul, Steve Self
and Nick Cox, among others, cannot be overstressed.  Do your data
management with do files, keep records, annotate, etc. etc.  I make too
many errors when I don't follow this advice.  Sometimes you get into a
bind with a client on the phone and you fail to heed this - and it comes
back to bite you in the behind - and you end up wasting inordinate
amounts of time.  Take it slowly and carefully - the time you spend at
the beginning more than compensates for time at the end.

Tony

Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Friedrich
Huebler
Sent: Thursday, November 13, 2008 2:39 PM
To: [email protected]
Subject: Re: st: resend

Tony,

If all dates are from 1900 to 1999 you can use the following command
before you convert the dates.

. replace date = substr(date,1,6) + "19" + substr(date,7,2) if
length(date) == 8

Friedrich

On Thu, Nov 13, 2008 at 5:23 PM, Lachenbruch, Peter
<[email protected]> wrote:
> I sent this earlier today, but it didn't appear on the list.  Let's
try
> again - sometimes my posts don't appear.
>
> I converted an Excel spreadsheet using StatTransfer and all of the
> variables came through as strings.  I converted a date variable using
> the command
> gen daten=date(date,"MDY")
> and about half of the dates came through just fine.  However, some
dates
> did not convert:
>      ----------------------|
> 131. | 10/10/1986      9779 |
> 132. | 03/21/1995     12863 |
> 133. | 09/26/1995     13052 |
> 134. | 04/03/1996     13242 |
> 135. |                    . |
>     |----------------------|
> 136. |   09/15/90         . |
> 137. |   03/15/91         . |
> 138. |   12/15/98         . |
> 139. |   07/15/86         . |
> 140. |   02/15/87         . |
>     |----------------------|
>
> The left column is the string variable, the right column is the julian
> date (I later convert to a date format, and the ones that do convert
are
> correct).
> I thought the problem might be extra spaces, so I tried ltrim and
rtrim
> to get rid of them, but it didn't work.
> I suspect others may have seen this problem - it's a pain in the neck
to
> do the conversion, but I did it manually.
> Does anyone have an idea what might be happening?
>
> Tony
>
> Peter A. Lachenbruch
> Department of Public Health
> Oregon State University
> Corvallis, OR 97330
> Phone: 541-737-3832
> FAX: 541-737-4001
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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