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: RE: re. strings and non-string: the month case


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: RE: re. strings and non-string: the month case
Date   Thu, 21 Nov 2013 16:22:07 +0000

understanding what it does and doesn't do is important.

Joe is creating a daily date from monthly information alone and then
extracting the month. That works because it is what is wanted, but the
dates themselves are 1 Jan 1960, 1 Feb 1960, and so forth as without a
day of the month Stata assumes 1 and without a year it assumes 1960.
You discard that day and year  information in this case, but know how
the trick was done.

Nick
[email protected]


On 21 November 2013 16:04, Joe Canner <[email protected]> wrote:
> Panos,
>
> In conjunction with -encode-, as suggested by Richard Goldstein, you might want to use the following statement to convert month names to month numbers:
>
> . gen month_num=month(date(MONTH,"M"))

PAPANIKOLAOU P.

> I have got a string variable: MONTH, where records the months of the year (e.g., January, February and so forth) on micro-data basis.
> Would you please assist me how best I would attach a set of label values where 1 refers to January, 2 is for February and so forth.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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