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]

st: Problem using date() and format


From   Jen Zhen <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index