Statalist


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

st: Re: Re: Extracting Time from Excel Sheet


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Re: Extracting Time from Excel Sheet
Date   Mon, 23 Feb 2009 21:38:05 +0100

<>

I swear I sent this post only once...

HTH
Martin _______________________ ----- Original Message ----- From: "Martin Weiss" <martin.weiss1@gmx.de>
To: <statalist@hsphsun2.harvard.edu>
Sent: Monday, February 23, 2009 9:09 PM
Subject: st: Re: Extracting Time from Excel Sheet


<>
I am sure there is an easier way to achieve this...

*******
clear*
input str24 var1
"Sep/09/1998 08:42:00 PM"
end
g var2=word(var1,-1)
g var3=word(var1,2)
g var4=clock(var3, "hms")
g var5=hh(var4)
g var6=string(var5)+" "+ var2
drop var2-var5
l
*******


HTH
Martin _______________________ ----- Original Message ----- From: <jasonm@ucla.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Monday, February 23, 2009 8:37 PM
Subject: st: Extracting Time from Excel Sheet


I want to extract the time from v1
Sep/09/1998 08:42:00 PM
where v1 is
str24  %24s
However, all I can extract is
08:42:00 PM
when using substr.
I would like to extract the hours (eg 8) and PM or AM.
Any suggestions?

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