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 on April 23, and its replacement, 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 <>
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,
*   For searches and help try:

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