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: Drop Observations if Greater than A Particular Date


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

Lisa,

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")


Steve

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


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