Statalist


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

st: AW: AW: Using dates


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: AW: Using dates
Date   Wed, 15 Apr 2009 16:31:51 +0200

<> 

Sorry about the last line in my example, Linn should omit it. If you format
in the fashion I did in that line, Stata thinks that "1" denotes Feburary
(of 1960) which is not your intention...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Mittwoch, 15. April 2009 16:12
An: [email protected]
Betreff: st: AW: Using dates 

<> 


Use this example:

*************
clear*
inp str19 date
20090102
20090203
20090405
end

compress

generate double mydate = date(date, "YMD")
format mydate %td

g year=year(mydate)
g month=month(mydate)
g day=day(mydate)

format  month %tmmon

list, noobs
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Linn Renée
Naper
Gesendet: Mittwoch, 15. April 2009 15:39
An: [email protected]
Betreff: st: Using dates 

Hi
I work with sdv-files where I have a variable displaying dates.

The date is reported as 20090102 etc (January 2nd 2009).
And the variable has storage type str19 and display format is %19s.

My question is how I should make Stata read this as a date, and moreover
being able to generate additional variables indicating week day, week
number, month and year from this variable.

Thanks
Linn

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index