# Re: st: min and max with dates

 From Ana Gabriela Guerrero Serdan To statalist@hsphsun2.harvard.edu 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

> 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
> for the minimum:
> sort CODE newdate1
> by(CODE): egen beg=min(newdate1)
>
> Quite similarly you proceed to the end dates.
>
> Best regards,
>
>
> On 10/8/07, Ana Gabriela Guerrero Serdan
> <ag_guerreroserdan@yahoo.com> 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.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/
```