Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: RE: RE: RE: Change string to year and month date


From   "DeMichele, Matthew" <mdemichele@rti.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: RE: Change string to year and month date
Date   Fri, 18 Oct 2013 11:50:32 -0400

Thanks so much for the responses. I will look into the tip and try the
different approaches mentioned as either monthly dates or the "15th"
suggestion are more precise that what I'm using now. Thanks again!

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Friday, October 18, 2013 11:38 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: RE: RE: Change string to year and month date

Using 15 and even better ways to impute were discussed in

SJ-12-1 dm0062  . . . . . . . . . Stata tip 105: Daily dates with
missing days
        . . . . . . . . . . . . . . . . . . . . .  S. J. Samuels and N.
J. Cox
        Q1/12   SJ 12(1):159--161                                (no
commands)
        presents strategies for dealing with daily dates where
        some observations only provide the month and year

Nick
njcoxstata@gmail.com


On 18 October 2013 16:33, Joe Canner <jcanner1@jhmi.edu> wrote:
> Got it.  If you wanted your ages to be more precise, you could impute
"15" for the birth day for each patient.  This would only be off by
about 15 days in either direction and would be more accurate than using
just year.  Or, as Nick just pointed out, you can use monthly dates,
which will entail converting your admission dates to monthly dates.
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of DeMichele,
Matthew
> Sent: Friday, October 18, 2013 11:28 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: RE: Change string to year and month date
>
> I didn't really think about the underlying framework of dates stored
in Stata. And, it might be that my needs can be met by simply extracting
the year only (which I have done). I have a date of birth variable in
which the day was removed for confidentiality reasons. I wanted to
calculate age of admissions and exposure types of variables, but it
seems best to just compute these as years of age.
>
> Thank you, Matthew
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Joe Canner
> Sent: Friday, October 18, 2013 11:24 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: Change string to year and month date
>
> Matthew,
>
> A Stata date variable without a day doesn't make much sense, since a
date variable is the number of days since 1/1/1960.  Please clarify what
it is you intend to do with this variable so that we can give the best
advice on how to proceed.
>
> Regards,
> Joe Canner
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of DeMichele,
Matthew
> Sent: Friday, October 18, 2013 11:16 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Change string to year and month date
>
> I'm trying to create a date variable using only the year and the month
from a string variable formatted as YYYYMM. For example, 200405 = May,
2004. I ran the syntax below, but this results in DAY appearing in the
first two columns as "01" such that the example above would be
01May2004.
>
> gen DATE_OF_BIRTH3= date(DATE_OF_BIRTH2, "YM") format DATE_OF_BIRTH3
%td

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index