Statalist


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

Re: st: min and max with dates


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: min and max with dates
Date   Mon, 8 Oct 2007 18:08:10 +0200

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/



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