Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: Problems with date format


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Problems with date format
Date   Tue, 7 Jun 2011 14:38:39 +0100

Should be mdy(1,1,1993) 

Nick 
n.j.cox@durham.ac.uk 


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: 07 June 2011 12:30
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Problems with date format

Stata understands 01011993 just as an integer 1011993 or 1,011,993. So
all your daily dates are in practice less than that. I don't know why
you thought Stata would know that you meant a date equivalent, but it
does not read minds in that way.

gem disability92=  exit2 < mdy(11, 1, 1993)

should be closer to what you want. Note that the two statements, one
-generate-, the second -replace-, can be reduced to one as above.

Nick

On Tue, Jun 7, 2011 at 12:13 PM, Morten Støver <morten.stover@ntnu.no> wrote:
> I'm trying to make dummy-variables for whether people has received
> disability pension up to a certain date. If the respondents have received it
> before 1993, before 1994, etc.
>
> I'm trying with this code, where "exit2" is the date of disability pension:
>
> gen disability92=0
> replacedisability92=1 if exit2<01011993
> gen disability93=0
> replace disability93=1 if exit2<01011994
>
> This code makes all my respondents with disability pension in the follow
> up-period have value 1, instead of only the respondents before the dates
> 01011993, 01011994, etc.
>
> So I guess there have to be a problem with the date format, and when I run
> "codebook exit2" I get:
>
> type:  numeric daily date (int)
>
>                 range:  [10958,17623]                units:  1
>       or equivalently:  [01jan1990,01apr2008]        units:  days
>         unique values:  295                      missing .:  0/2784
>
> I guess there is a quite simple solution to this, but now I'm just stuck. I
> hope someone can help. I'm running Stata 11.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index