Statalist


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

Re: AW: RE: st: how to change specific string variable into date variable?


From   gjhxmu@sina.com
To   statalist<statalist@hsphsun2.harvard.edu>
Subject   Re: AW: RE: st: how to change specific string variable into date variable?
Date   Thu, 13 Aug 2009 16:18:16 +0800

Martin,
I am sorry. 
You wrote "failed to find the reference Nick cites". I found it, so I told you. 
NO dispute. No criticism. 
Forgive me if anything wrong.

Best regards,
Rose




----- Original Message -----
From: Martin Weiss <martin.weiss1@gmx.de>
To: <statalist@hsphsun2.harvard.edu>
Subject: AW: RE: st: how to change specific string variable into date variable?
Date: 2009-8-13 15:57:33


<> 


I am not disputing this fact! I failed to find the reference in spite of a
comprehensive scan of this very help file. So the criticism was entirely
directed at myself ...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von gjhxmu@sina.com
Gesendet: Donnerstag, 13. August 2009 09:57
An: statalist
Betreff: Re: RE: st: how to change specific string variable into date
variable?

Martin,
what Nick cites is in the help for -dates_and_times-.


Best regards,
Rose.

----- Original Message -----
From: Martin Weiss <martin.weiss1@gmx.de>
To: <statalist@hsphsun2.harvard.edu>
Subject: RE: st: how to change specific string variable into date variable?
Date: 2009-8-13 04:48:58


<>

I thought about this solution, but failed to find the reference Nick
cites... Would it not make more sense to leave the second -substr()- free to
take a month consisting of one digit or two by replacing "2" with a dot?


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Mittwoch, 12. August 2009 22:25
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: how to change specific string variable into date variable?

Martin Weiss suggested a solution which worked fine. Rose's problem was
left unexplained, however, yet the explanation is given directly in the
help for -dates_and_times-. 

For functions like -monthly()-, 

"The pair of numbers to be translated must be separated by space or
punctuation. No extra characters are allowed." 

As Rose's dates are run together, this condition is not satisfied. 

g date2=monthly(substr(date, 1, 4) + " " + substr(date, 5, 2),"YM")

would have been a direct solution. Where someone has seen fit to put
year and month together, we insert a space between them. 

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

Rose <gjhxmu@sina.com> 

Something wrong happened when changing the string variable into date
variable.

clear
input country:mylabel /* 
*/ str10 date, auto 
Argentina "199001"
Argentina "199001"
Argentina "199001"
Argentina "199002"
Argentina "199003"
Argentina "199004"
Argentina "199004"
Argentina "199004"
Argentina "199004"
Argentina "199101"
Argentina "199101"
Argentina "200803"
Argentina "200804"
Argentina "200804"
Brazil "199001"
Brazil "199002"
Brazil "199002"
Brazil "199003"
Brazil "199003"
Brazil "199003"
Brazil "199003"
end
g date2=monthly(date,"YM")

The result showed "21 missing values generated"

Anything wrong? How to correct it ?

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


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

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


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

*
*   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   |   What's new   |   Site index