Statalist


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

st: AW: Transforming a decimal number into hours and minutes


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Transforming a decimal number into hours and minutes
Date   Fri, 7 Aug 2009 14:05:17 +0200

<> 

" a decimal number cannot be turned in to a string"



How about 

*************
help tostring
*************

?


HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Peer Skov
Gesendet: Freitag, 7. August 2009 12:54
An: [email protected]
Betreff: st: Transforming a decimal number into hours and minutes

Hi listers,
I am working with a survey dataset. The individuals have all been asked to
report how much time they have spent on a specific activity. The answers are
recorded in the dataset as a numeric variable the provided answers are
integers (hours worked). 
I want to assign conditional means to the individuals who have not answered
the hour question. Calculating the means leads to a decimal number and
therefore I need to transform the decimal-part into minutes. Since Statas
date function only work with strings and a decimal number cannot be turned
in to a string I am not sure how I can solve it.
 
Code:
bysort edu: egen hoursA=mean(hours)
replace hours=hoursA if hours ==. & active == 1
 
Example.
I need to turn 3.89 into 3.53
 
All thoughts are much appreciated.
Best,
Peer.
_________________________________________________________________
Drag n? drop?Get easy photo sharing with Windows Live? Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx
*
*   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