Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert Hours and Mins to Total hrs or Total mins?

833 views
Skip to first unread message

Lawrence

unread,
Dec 12, 2006, 2:01:48 AM12/12/06
to
Hi Guys!

Warm greetings to all. In my data file we collect the respondent usage
about a particular product in hrs and mins. The respondent can answer
hrs or mins or both. I want a new variables for todal hrs and total
mins. Data captured in the following way.


Hrs Mins
8 .
5 .
0 30
1 1
5 7
. 15
1 0
1 .
0 5
5 5
5 .


Thanks,

Lawrence

neila...@msn.com

unread,
Dec 12, 2006, 3:18:33 AM12/12/06
to
How would you go about it without a computer?
Neila

Lawrence

unread,
Dec 12, 2006, 5:09:16 AM12/12/06
to

This data file in SPSS format.

Thanks,

Lawrence

michael....@tangozebra.com

unread,
Dec 12, 2006, 9:37:50 AM12/12/06
to
i would create a variable to count sysmis valuesfor each hrs and mins

Count HRSMIS = hrs(missing).
Count MinMIS = min(missing).

and then use and if clause to clauclate the zero value back onto the
variable

If (hrsmis = 1) hrs =0.
If (minmis = 1) min =0.

from here you can then use you favourite method to work out mins or
hours

i.e
Compute Tmins = hrs*60 + mins.
Exe.

HtH

Mike

michael....@tangozebra.com

unread,
Dec 12, 2006, 9:41:37 AM12/12/06
to
I think i may have read your question wrong.

If you are referrering to total by all respondents i would create and
dummy variable and then aggr by that

Compute dummy=1.
AGGREGATE
/OUTFILE=*
MODE=ADDVARIABLES
/BREAK=Dummy
/Hrstot = SUM(Hrs) /Minstot= SUM(mins).

this will give you total minutes and total ours, you can then combine
the two similar to how i stated earlier

Bruce Weaver

unread,
Dec 12, 2006, 9:52:37 AM12/12/06
to
michael....@tangozebra.com wrote:
> i would create a variable to count sysmis valuesfor each hrs and mins
>
> Count HRSMIS = hrs(missing).
> Count MinMIS = min(missing).
>
> and then use and if clause to clauclate the zero value back onto the
> variable
>
> If (hrsmis = 1) hrs =0.
> If (minmis = 1) min =0.


Why not do all that in one step, like this:

RECODE hrs min (SYSMIS=0) (else=copy).
exe.


>
> from here you can then use you favourite method to work out mins or
> hours
>
> i.e
> Compute Tmins = hrs*60 + mins.
> Exe.
>
> HtH
>
> Mike
>


--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir

michael....@tangozebra.com

unread,
Dec 12, 2006, 10:13:43 AM12/12/06
to
Good call,

Much better way of doing it

Mike

neila...@msn.com

unread,
Dec 12, 2006, 4:17:26 PM12/12/06
to

I don't have SPSS on this box to test, BUT I'll bet the following
flies!

Compute totmin = SUM(hrs*60,mins).
LOL, Neila

Robert Jones

unread,
Dec 13, 2006, 5:14:47 AM12/13/06
to

what about Compute Tmins = max(hrs,0)*60 + max(mins,0)

neila...@msn.com

unread,
Dec 13, 2006, 2:52:22 PM12/13/06
to
Why?

Lawrence

unread,
Dec 14, 2006, 9:34:21 AM12/14/06
to
Hi Guys!

Thanks for all of your input on my query. I used the follwing syntax
and got the total mins exactly. I calculated total hrs, but in some
cases I got different value. Why it's coming? Please look the 4-6, 9
and 10 records. The total hrs come differently. How to interpret this?


Recode hrs mins (sysmis=0) (else=copy).
Compute totmin = SUM(hrs*60,mins).
compute tothrs=totmin/60.
exe.


hrs mins totmins tothrs
---- ----- ------ ------
8 0 480.00 8.00
5 0 300.00 5.00
0 30 30.00 .50
1 1 61.00 1.02
5 7 307.00 5.12
0 15 15.00 .25
1 0 60.00 1.00
1 0 60.00 1.00
0 5 5.00 .08
5 5 305.00 5.08
5 0 300.00 5.00

neila...@msn.com

unread,
Dec 14, 2006, 1:51:12 PM12/14/06
to
??????
Neila

Robert Jones

unread,
Dec 14, 2006, 2:48:20 PM12/14/06
to

message snipped

1) dividing an integer hours field by 60 will give the results as
hours and decimal fractions of hours

2) Neila's sum(hrs*60,mins) as the complete solution is much better
than my max(hrs,0)+max(mins,0) as a partial solution that still needs
summing.

I had mistakenly understood/misread that the SUM function required all
numerics in the fields from the Help description, but was obviously
wrong as nulls/non numerics are obviously just ignored.

Robert

neila...@msn.com

unread,
Dec 14, 2006, 4:57:02 PM12/14/06
to

Robert Jones wrote:
> message snipped
>
> 1) dividing an integer hours field by 60 will give the results as
> hours and decimal fractions of hours
>

It is stored as a **double** , not integer!!!
The issue is the default format (F8.2).
See FORMAT commaand eg FORMAT var (10.6 will give you 6 decimal places


> 2) Neila's sum(hrs*60,mins) as the complete solution is much better
> than my max(hrs,0)+max(mins,0) as a partial solution that still needs
> summing.
>
> I had mistakenly understood/misread that the SUM function required all
> numerics in the fields from the Help description, but was obviously
> wrong as nulls/non numerics are obviously just ignored.

Sorta ;-)
>
> Robert

Lawrence

unread,
Dec 15, 2006, 4:47:19 AM12/15/06
to
How to interpret this total hrs?


hrs mins totmins tothrs
5 7 307.00 5.12


this tothrs should be 5.07.


Thanks,

Lawrence.

Brendan Halpin

unread,
Dec 15, 2006, 4:59:58 AM12/15/06
to
"Lawrence" <lawrenc...@gmail.com> writes:

> hrs mins totmins tothrs
> 5 7 307.00 5.12
>
>
> this tothrs should be 5.07.

Lawrence,

Divide 7 by 60 and think again.

Brendan
--
Brendan Halpin, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan...@ul.ie http://www.ul.ie/sociology/brendan.halpin.html

Lawrence

unread,
Dec 15, 2006, 6:15:42 AM12/15/06
to
Hello Brendan,


You are absolutely right! Now I got my point. Thanks lot.


Thanks,

Lawrence.

Robert Jones

unread,
Dec 16, 2006, 10:22:35 AM12/16/06
to

neila...@msn.com wrote:

> Robert Jones wrote:
> > message snipped
> >
> > 1) dividing an integer hours field by 60 will give the results as
> > hours and decimal fractions of hours
> >
>
> It is stored as a **double** , not integer!!!
> The issue is the default format (F8.2).
> See FORMAT commaand eg FORMAT var (10.6 will give you 6 decimal places
> > 2) Neila's sum(hrs*60,mins) as the complete solution is much better
> > than my max(hrs,0)+max(mins,0) as a partial solution that still needs
> > summing.

Yes thanks, I think I am digging a hole for myself, I meant what you
said.

Robert

0 new messages