Robert Bozick posted about a problem that he is having with flagging dates
earlier than a cut-off date:
---------------------excerpted posting------------------------------------------
I have been staring at this for a few hours -- am I missing something obvious?
I keep thinking it has soemthing to do with the gen entry1 command...I am not
sure. Again, I am relatively new to using dates in STATA. How can I get STATA
to create a variable that indicates only those who enrolled before September 1,
1989?
-------------------------------------------------------------------------------
Robert's code seems to work for me. The ado-file below takes his code verbatim
and produces the following output.
Sprojen~t projentr~t m1 d1 y1 edate1 entry1
18 Jul 95 1995-07-18 9 1 1989 1989-09-01 .
15 May 77 1977-05-15 9 1 1989 1989-09-01 1
15 May 77 1977-05-15 9 1 1989 1989-09-01 1
31 Jul 94 1994-07-31 9 1 1989 1989-09-01 .
18 May 96 1996-05-18 9 1 1989 1989-09-01 .
15 Oct 79 1979-10-15 9 1 1989 1989-09-01 1
10 Jan 09 1909-01-10 9 1 1989 1989-09-01 1
12 Oct 96 1996-10-12 9 1 1989 1989-09-01 .
15 Jan 89 1989-01-15 9 1 1989 1989-09-01 1
13 Nov 00 2000-11-13 9 1 1989 1989-09-01 .
30 Jun 89 1989-06-30 9 1 1989 1989-09-01 1
I suspect that his problem lies in the form of the variable projentrydt, which
might not be what it appears. See , for example, the school entry date of
January 10, 1909. This seems to signal something might not be as intended.
Joseph Coveney
-------------------------------------------------------------------------------
clear
set more off
input str9 Sprojentrydt
"18 Jul 95"
"15 May 77"
"15 May 77"
"31 Jul 94"
"18 May 96"
"15 Oct 79"
"10 Jan 09" // Sure about this?
"12 Oct 96"
"15 Jan 89"
"13 Nov 00"
"30 Jun 89"
end
generate int projentrydt = date(Sprojentrydt, "dmy", 2003)
// Robert's code starts here . . .
gen m1 = 09
gen d1 = 01
gen y1 = 1989
gen edate1 = mdy(m1, d1, y1)
gen entry1 = 1 if projentrydt < edate1
// and ends here.
quietly compress // optional
quietly aformat _all // optioal
format projentrydt edate1 %dCY-N-D
clist, noobs
exit
--------------------------------------------------------------------------------
*
* 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/