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]

RE: st: string translation : date & time


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: string translation : date & time
Date   Wed, 26 Oct 2011 14:25:48 +0100

No bug here. (-monthly()- does seem to have problems with run-together dates lacking punctuation, not the issue here.)

. l

     +--------+
     |   var1 |
     |--------|
  1. | jan-90 |
  2. | jan-99 |
  3. | jan-00 |
  4. | jan-10 |
     +--------+

. gen var2 = monthly(var1, "MY", 2050)

. format var2 %tm

. l

     +-----------------+
     |   var1     var2 |
     |-----------------|
  1. | jan-90   1990m1 |
  2. | jan-99   1999m1 |
  3. | jan-00   2000m1 |
  4. | jan-10   2010m1 |
     +-----------------+

For a mix of years that spans a century-end, the third argument must be somewhere in the middle of a century. See -help dates_and_times- for more. The third argument is described in the help as "topyear", and it will typically not be 2000. 

Nick 
n.j.cox@durham.ac.uk 


Abhimanyu Arora

> I appended the following command to the earlier ones.

> replace temp=monthly(date,"MY",2100) if yofd(dofm(monthly(date,"MY",2000)))<1920

> While I haven't been able to figure out the explanation still,
> nevertheless, I am a bit hesitant to cry bug!

Abhimanyu Arora

>> I just got myself in a puzzling situation.

>> I had a variable string variable date taking up values
>> Jan-90...Jan-99...Jan-00...Jan-01...Jan-10 and so on for different
>> months.
>> Making use of the time and date functions I typed the following commands
>>
>> gen temp=monthly(date,"MY",2000) *2000 is the base year*
>>
>> Subsequently, -format temp %tm - yields for the above months
>> respectively, 1990m1...1999m1...2000m1...1901m1...1910m1 and so on.
>>
>> I an eager to know what could be the possible reason? And possible
>> rectifying steps (both in terms of the possible commands I used
>> initially and suppose given the output, into the desired form which is
>> needless to say is 2001m1, 2010m1 etc?


*
*   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