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 on April 23, and its replacement, is already up and running.

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

Re: st: Drop Observations if Greater than A Particular Date

From   Steve Nakoneshny <>
To   "" <>
Subject   Re: st: Drop Observations if Greater than A Particular Date
Date   Tue, 31 Jul 2012 16:17:49 -0600


When you changed your date var to display as %td the only thing you changed was how you got to see it in your dataset, NOT the underlying number.
Type -di date("20060720","YMD")- to see what the value for that date is given the date format you specified.

You can write it out in two lines as:
di date("20060720","YMD")
drop if date > 17002

Or more concisely as:
drop if date > date("20060720","YMD")


On 2012-07-31, at 3:59 PM, Lisa Wang wrote:

> Hi all,
> I have a simple problem but don't understand why it is currently not
> working, so any help would be appreciated. I have imported data
> (including dates) into Stata from a csv file and then ran code to
> change it into %td format
> -generate edate = date(date, "YMD") 		//translate string dates into lapsed dates
> format edate %td
> drop date
> rename edate date
> label variable date Date-
> I then would like to drop observations where the date is greater than
> 20-07-2006. I did -drop if date>20072006- but that does not drop any
> observations at all when I can see that there are instances where the
> date is greater than this.
> Do I have to convert my 20-07-2006 back into lapsed dates, then how do
> I work out what value this corresponds to? I would have thought it
> would be easier than this.
> Thank you for your suggestions,
> Lisa
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index