Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Problem using date() and format


From   Jen Zhen <jenzhen99@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Problem using date() and format
Date   Wed, 5 Sep 2012 17:23:20 +0200

Dear Statalisters,

I have a string variable with values 199301, 199302, 199303, ...,
199312, 199401, and so on.
I would like to convert it to a Stata date variable and then format it
so that when I browse the dataset values will be displayed as 1993m1,
1993m2, etc.
It should be totally straightforward after consulting -help date-, yet
I always get displayed wrong dates.

I tried (amongst others):

gen date=date(string,YM)
format date %tm

and at least one of those 2 lines of code must have been wrong, as I
get shown values like 2972m1

What should it be?

Thanks a lot and best regards,
JZ
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index