Statalist


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

Re: st: resend


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: resend
Date   Thu, 13 Nov 2008 17:40:19 -0500

Type
 view
and paste
 help dates_and_times##twodigit
into the viewer.

Or:

clear
input str10 d
"10/10/1986"
"03/21/1995"
"09/26/1995"
"04/03/1996"
"09/15/90"
"03/15/91"
"12/15/98"
"07/15/86"
"02/15/87"
end
gen n=date(d,"MDY",2020)
g daten=n
format daten %td
li

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/



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