Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: min and max with dates


From   Ana Gabriela Guerrero Serdan <[email protected]>
To   [email protected]
Subject   Re: st: min and max with dates
Date   Mon, 8 Oct 2007 09:40:17 -0700 (PDT)

Dear Sergiy, 

Thanks, I managed to swap the month first and then the
day. But when trying to calculate the minimum it says

by(CODE): egen beg=min(newdate1)
invalid syntax
r(198);

I been trying to calculate the mimimum of newdate 
without the sort and its also not possible... !?
Should I firs set the var as date? 


Gaby 

--- Sergiy Radyakin <[email protected]> wrote:

> Hello Ana Gabriela,
> 
> this will swap the day and month in the [string]
> variable Date1:
> gen newdate1=substr(Date1,3,2)+substr(Date1,1,2)
> As long as Date2 is always later than Date1, you
> care only about Date1
> for the minimum:
> sort CODE newdate1
> by(CODE): egen beg=min(newdate1)
> 
> Quite similarly you proceed to the end dates.
> 
> Best regards,
>    Sergiy Radyakin
> 
> 
> On 10/8/07, Ana Gabriela Guerrero Serdan
> <[email protected]> wrote:
> > Dear all,
> >
> > I have a very basic question but I havent find the
> > date commands when I only have day and month.
> >
> > I have information on interviews carried out and
> want
> > to know the range of interview per province
> (CODE), so
> > I want to calculate the min and max of the dates
> > within each province.
> >
> >
> > . list  CODE Date1 Date2 Date3
> >
> >       +-------------------------------+
> >       |    CODE   Date1 Date2 Date3   |
> >       |-------------------------------|
> >    1. |     01     2704               |
> >    2. |     01     2704   3004        |
> >    3. |     01     2704         1505  |
> >    4. |     01     2505               |
> >    5. |     01     2605               |
> >       |-------------------------------|
> >    6. |     02     2705   0106        |
> >    7. |     02     2805    0606       |
> >
> > etc..
> >
> > Can anyone help?
> >
> > thanks,
> > Gaby
> >
> >
> >
> >
> >      
>
____________________________________________________________________________________
> > Tonight's top picks. What will you watch tonight?
> Preview the hottest shows on Yahoo! TV.
> > http://tv.yahoo.com/
> >
> > *
> > *   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/
> >
> *
> *   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/
> 


Gaby Guerrero Serdan 

Deparment of Economics
Royal Holloway, University of London
TW20 OEX
Egham, Surrey
England, UK
http://www.rhul.ac.uk/economics/About-Us/postgrads.html
http://www.flickr.com/photos/49939890@N00/

Tel: +41788502082 (in switzerland)


       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index