![]() |
From | Arun Rajamohan <arajamoh@uwo.ca> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: date function |
Date | Wed, 06 Feb 2008 15:59:56 -0500 |
Hope this helps... +-----+ | mon | |-----| 1. | jan | 2. | feb | 3. | mar | 4. | apr | 5. | may | |-----| 6. | jun | +-----+ . gen dat=date(mon, "M") . l +-----------+ | mon dat | |-----------| 1. | jan 0 | 2. | feb 31 | 3. | mar 60 | 4. | apr 91 | 5. | may 121 | |-----------| 6. | jun 152 | +-----------+ . format dat %td . l +-----------------+ | mon dat | |-----------------| 1. | jan 01jan1960 | 2. | feb 01feb1960 | 3. | mar 01mar1960 | 4. | apr 01apr1960 | 5. | may 01may1960 | |-----------------| 6. | jun 01jun1960 | +-----------------+ . gen mon2=month(dat) . l +------------------------+ | mon dat mon2 | |------------------------| 1. | jan 01jan1960 1 | 2. | feb 01feb1960 2 | 3. | mar 01mar1960 3 | 4. | apr 01apr1960 4 | 5. | may 01may1960 5 | |------------------------| 6. | jun 01jun1960 6 | +------------------------+ . -Arun On Feb 6, 2008, at 3:42 PM, Visintainer, Paul wrote: Is there a date function that converts a string variable containing only the text of the month into a numeric version of the month? e.g.: X has string values October, April, December, etc. I want to create a new variable that is numeric with numbers 10, 04, 12, etc. I thought -monthly( )- would do it, but I can't seem to get the right syntax.
|
© Copyright 1996–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |