Interaction terms Significance of beta coefficients for males and females.

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Interaction terms Significance of beta coefficients for males and females.

Karen Wood


Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen


Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

Hector Maletta

Karen, I think the main effect (beta=0.455) is for both sexes; you do not have a separate coefficient for males. What you have is an interaction with sex, indicating that being female detracts 0.282 from the main effect, and (implicitly) being male detracts nothing. According to this interpretation, the effect of mathematics is 0.455 – 0.282=0.173 for females and 0.455 for males. The significance is p=0.000 for 0.455 and p=0.022 for the female deduction (-0.282). The estimates of both coefficients are significant at the 95% level, one of them at the 99% level (this means that, given these sample results, and assuming the linear model is true, you have 95% or 99% confidence, respectively, that the coefficients are not zero at the population level, though some small chance does remain that they ARE zero at the population level).

 

Hector


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Karen Wood
Sent: 16 April 2009 02:48
To: [hidden email]
Subject: Interaction terms Significance of beta coefficients for males and females.

 



Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen


Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

Swank, Paul R
In reply to this post by Karen Wood

Recode gender the opposite way  (females = 0, males – 1) and rerun. Then you get the test for females and the test for the difference between males and females.

 

Dr. Paul R. Swank,

Professor and Director of Research

Children's Learning Institute

University of Texas Health Science Center-Houston

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Karen Wood
Sent: Thursday, April 16, 2009 12:48 AM
To: [hidden email]
Subject: Interaction terms Significance of beta coefficients for males and females.

 



Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen

 

Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

David Greenberg
In reply to this post by Karen Wood
An argument can be made that dummy variables should not be standardized. A standardized variable tells you by how many standard deviations a dependent variable changes when an independent variable changes by one standard deviation. With a variable coded 0 and 1, one can compute a standardized variable, but what does this tell you? The effect of changing one's sex part way between being male and being female? This corresponds to an impossible condition. David Greenberg, Sociology Department, New York University

----- Original Message -----
From: Karen Wood <[hidden email]>
Date: Thursday, April 16, 2009 1:52 am
Subject: Interaction terms Significance of beta coefficients for males and females.
To: [hidden email]


> Hi
>
> I have a significant interaction term, mathematics*sex. I've coded
> males = 0 and females = 1.
>
> The standardized regression coefficients are 0.46 for males and 0.17
> for females.
>
> The SPSS output coefficients table has:
>
> mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000
>
> mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022
>
> Therefore as males are coded 0, the significance level of the main
> effect (sig. = 0) is appropriate and so for males beta = 0.455***.
>
> Without running separate analyses (which gives different results!!),
> how  can I determine the significance of the beta coefficient for females?
>
> Thanks
>
> Karen
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

Karen Wood
In reply to this post by Swank, Paul R

Yes thank you for your reply. Recoding is very logical  - thank you.

Karen




At 12:07 AM 17/04/2009, you wrote:
Recode gender the opposite way  (females = 0, males – 1) and rerun. Then you get the test for females and the test for the difference between males and females.
 
Dr. Paul R. Swank,
Professor and Director of Research
Children's Learning Institute
University of Texas Health Science Center-Houston
 
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Karen Wood
Sent: Thursday, April 16, 2009 12:48 AM
To: [hidden email]
Subject: Interaction terms Significance of beta coefficients for males and females.
 


Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen
 

Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

Karen Wood
In reply to this post by Hector Maletta

In response to Hector Maletta, Knowing that the -0.282 for the female deduction is significance still doesn't tell me whether the beta coefficient for females is significant (i.e., the beta = 0.173).
At 04:09 PM 16/04/2009, you wrote:
Karen, I think the main effect (beta=0.455) is for both sexes; you do not have a separate coefficient for males. What you have is an interaction with sex, indicating that being female detracts 0.282 from the main effect, and (implicitly) being male detracts nothing. According to this interpretation, the effect of mathematics is 0.455 – 0.282=0.173 for females and 0.455 for males. The significance is p=0.000 for 0.455 and p=0.022 for the female deduction (-0.282). The estimates of both coefficients are significant at the 95% level, one of them at the 99% level (this means that, given these sample results, and assuming the linear model is true, you have 95% or 99% confidence, respectively, that the coefficients are not zero at the population level, though some small chance does remain that they ARE zero at the population level).
 
Hector

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Karen Wood
Sent: 16 April 2009 02:48
To: [hidden email]
Subject: Interaction terms Significance of beta coefficients for males and females.
 


Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen

Reply | Threaded
Open this post in threaded view
|

Re: Interaction terms Significance of beta coefficients for males and females.

Karen Wood
In reply to this post by Karen Wood



Steve, can you please explain how that Recode works [ RECODE sex (0=1)(1=0) INTO nSex? ]. I must be doing something wrong in the way I'm changing the o's and 1's around.

Thanks again

Karen

At 11:35 PM 16/04/2009, you wrote:
Karen,
               Rerun regression analysis; the coefficients for mathematics will reflect the relationship for females .
 
                Note. When sex is 0 the coefficients  for mathematics express the relationship between the outcome and mathematics for males :
                                Outcome = b0 + b1(male=0) + b2(math) + b3*(male=0)*(math) = b0 + b2(math) .
 
Hope this helps. -Steve
 
 
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Karen Wood
Sent: Thursday, April 16, 2009 1:48 AM
To: [hidden email]
Subject: Interaction terms Significance of beta coefficients for males and females.
 


Hi

I have a significant interaction term, mathematics*sex. I've coded males = 0 and females = 1.

The standardized regression coefficients are 0.46 for males and 0.17 for females.

The SPSS output coefficients table has:

mathematics (main effect) beta = 0.455, t = 3.661, sig. = 0.000

mathematics*sex: beta = -0.282, t = -2.328, sig. = 0.022

Therefore as males are coded 0, the significance level of the main effect (sig. = 0) is appropriate and so for males beta = 0.455***.

Without running separate analyses (which gives different results!!), how  can I determine the significance of the beta coefficient for females?

Thanks

Karen
 

Reply | Threaded
Open this post in threaded view
|

datediff results

parisec
In reply to this post by Swank, Paul R
Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format
so that  -0:04:00 the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Oliver, Richard
Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format
so that  -0:04:00 the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Tuerk, Elena
I obtain the correct results as well, although it does not like the conversion of the timedif1_2 to hh:mm:ss from numeric and eliminates the negative number.



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Oliver, Richard
Sent: Monday, June 22, 2009 2:37 PM
To: [hidden email]
Subject: Re: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format
so that  -0:04:00 the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

parisec
In reply to this post by Oliver, Richard
thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Oliver, Richard
Hmm...that does indeed look like seconds.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Monday, June 22, 2009 1:46 PM
To: [hidden email]
Subject: Re: datediff results

thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Oliver, Richard
In reply to this post by parisec
Oops. My bad. The result returned is a number of minutes, not the number of seconds in that many minutes. You should just use F format. Applying a time format interprets the underlying value as a number of seconds; so applying the time format to a value of 7 results in a display format of 0:00:07.

-----Original Message-----
From: Oliver, Richard
Sent: Monday, June 22, 2009 1:58 PM
To: 'Parise, Carol A.'; [hidden email]
Subject: RE: Re: datediff results

Hmm...that does indeed look like seconds.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Monday, June 22, 2009 1:46 PM
To: [hidden email]
Subject: Re: datediff results

thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

parisec
That did the trick. I now have a round number of the difference in
minutes in numeric format.

Thanks.


-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 12:12 PM
To: Oliver, Richard; Parise, Carol A.; [hidden email]
Subject: RE: Re: datediff results

Oops. My bad. The result returned is a number of minutes, not the number
of seconds in that many minutes. You should just use F format. Applying
a time format interprets the underlying value as a number of seconds; so
applying the time format to a value of 7 results in a display format of
0:00:07.

-----Original Message-----
From: Oliver, Richard
Sent: Monday, June 22, 2009 1:58 PM
To: 'Parise, Carol A.'; [hidden email]
Subject: RE: Re: datediff results

Hmm...that does indeed look like seconds.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:46 PM
To: [hidden email]
Subject: Re: datediff results

thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Oliver, Richard
Actually, it's the truncated, not rounded, value. This may or may not be an important distinction for you. Note the difference in the last value between the DateDiff function and the result obtained by simply dividing the raw difference by 60 (since internally the values are stored as seconds):

data list list /time1 time2 (2time12.2).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
2:27:00.00 2:20:00.11
end data.
compute timedif1=datediff(time1, time2, "minutes").
compute timedif2=(time1-time2)/60.
formats timedif1 timedif2 (f8.5).
list.



       time1        time2 timedif1 timedif2

  2:19:59.99   2:23:59.99 -4.00000 -4.00000
  2:27:00.00   2:20:00.00  7.00000  7.00000
  2:27:00.00   2:20:00.11  6.00000  6.99817


Number of cases read:  3    Number of cases listed:  3

At the minute level, you may be better off with the simple arithmetic solution rather than using the DateDiff function.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A.
Sent: Monday, June 22, 2009 2:59 PM
To: [hidden email]
Subject: Re: datediff results

That did the trick. I now have a round number of the difference in
minutes in numeric format.

Thanks.


-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 12:12 PM
To: Oliver, Richard; Parise, Carol A.; [hidden email]
Subject: RE: Re: datediff results

Oops. My bad. The result returned is a number of minutes, not the number
of seconds in that many minutes. You should just use F format. Applying
a time format interprets the underlying value as a number of seconds; so
applying the time format to a value of 7 results in a display format of
0:00:07.

-----Original Message-----
From: Oliver, Richard
Sent: Monday, June 22, 2009 1:58 PM
To: 'Parise, Carol A.'; [hidden email]
Subject: RE: Re: datediff results

Hmm...that does indeed look like seconds.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:46 PM
To: [hidden email]
Subject: Re: datediff results

thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

parisec
you are correct. i prefer the rounded versus the truncated. thank you!

carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 1:27 PM
To: Parise, Carol A.; [hidden email]
Subject: RE: Re: datediff results

Actually, it's the truncated, not rounded, value. This may or may not be
an important distinction for you. Note the difference in the last value
between the DateDiff function and the result obtained by simply dividing
the raw difference by 60 (since internally the values are stored as
seconds):

data list list /time1 time2 (2time12.2).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
2:27:00.00 2:20:00.11
end data.
compute timedif1=datediff(time1, time2, "minutes").
compute timedif2=(time1-time2)/60.
formats timedif1 timedif2 (f8.5).
list.



       time1        time2 timedif1 timedif2

  2:19:59.99   2:23:59.99 -4.00000 -4.00000
  2:27:00.00   2:20:00.00  7.00000  7.00000
  2:27:00.00   2:20:00.11  6.00000  6.99817


Number of cases read:  3    Number of cases listed:  3

At the minute level, you may be better off with the simple arithmetic
solution rather than using the DateDiff function.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 2:59 PM
To: [hidden email]
Subject: Re: datediff results

That did the trick. I now have a round number of the difference in
minutes in numeric format.

Thanks.


-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 12:12 PM
To: Oliver, Richard; Parise, Carol A.; [hidden email]
Subject: RE: Re: datediff results

Oops. My bad. The result returned is a number of minutes, not the number
of seconds in that many minutes. You should just use F format. Applying
a time format interprets the underlying value as a number of seconds; so
applying the time format to a value of 7 results in a display format of
0:00:07.

-----Original Message-----
From: Oliver, Richard
Sent: Monday, June 22, 2009 1:58 PM
To: 'Parise, Carol A.'; [hidden email]
Subject: RE: Re: datediff results

Hmm...that does indeed look like seconds.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:46 PM
To: [hidden email]
Subject: Re: datediff results

thank you. you made be go back and look at the 2 times that were input
and sure enough, time 1 is in error for all of them. nice to know at
least my syntax is correct but feel like a doofus for posting.

one last question and i won't take anymore time.
is there a way of having the difference show up in the "minutes" section
of the time? i.e. -0:04:00. It seems that these are in the "seconds"
portion of the  field.

thank you.
carol

-----Original Message-----
From: Oliver, Richard [mailto:[hidden email]]
Sent: Monday, June 22, 2009 11:37 AM
To: Parise, Carol A.; [hidden email]
Subject: RE: datediff results

Curious. I get the correct results:

data list list /time1 time2 (2time10).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
end data.
numeric timedif_2 (time10).
compute timedif_2=datediff(time1, time2, "minutes").
list.

     time1      time2  timedif_2

   2:19:59    2:23:59   -0:00:04
   2:27:00    2:20:00    0:00:07


Number of cases read:  2    Number of cases listed:  2

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Parise, Carol A.
Sent: Monday, June 22, 2009 1:21 PM
To: [hidden email]
Subject: datediff results

Hi all,

I'm hoping someone can point out my error here...

I have 2 date/times and i need to compute the difference between the 2
times.

I used the following syntax:

numeric  TimeDif1_2 (Time10).
        compute TimeDif1_2=Datediff(Time1,Time2, "minutes").
                execute.

...it returned these results.

Time1        Time2      TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05

2:27:00.00 2:20:00.00 0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's
close?

Ultimately, i'd like the results in hh:mm:ss format so that  -0:04:00
the second one would be 0:07:00

I suspect this has something to do with the format (time10).

TIA for any assistance.

Carol

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command SIGNOFF SPSSX-L For a list
of commands to manage subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

Richard Ristow
In reply to this post by parisec
At 02:21 PM 6/22/2009, Parise, Carol A. wrote:

I have 2 date/times and I need to compute the difference between the 2
times. I used the following syntax:

numeric TimeDif1_2 (Time10).
compute TimeDif1_2=Datediff(Time1,Time2, "minutes").


...it returned these results.

Time1      Time2       TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05
2:27:00.00 2:20:00.00  0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's close?

Richard Oliver got this right, but I'd like to expand on it.

There are two ways to take the difference between two times (or date-times): simple subtraction (the old way), and DATEDIFF (the new way). They behave very differently:

. SPSS date-time values are in seconds, so simple subtraction gives a difference in seconds, which is a valid SPSS time value. The value should be displayed with a time format.

. DATEDIFF returns an integer, giving the (truncated) value of the difference in the units specified. It should be displayed with an F format (with no decimals).

Both the old and the new ways have their uses. In your case, you write,

I'd like the results in hh:mm:ss format so that  -0:04:00 the second one would be 0:07:00

If you want the result as a time value, use simple subtraction. Starting with input data
|-----------------------------|---------------------------|
|Output Created               |25-JUN-2009 19:13:29       |
|-----------------------------|---------------------------|
        time1         time2

   2:19:59.99    2:23:59.99
   2:27:00.00    2:20:00.00
   1:19:45.00    3:41:16.00
  13:14:15.25   16:17:18.50

Number of cases read:  4    Number of cases listed:  4

you can compare the results with DATEDIFF and with subtraction. (I think you had the time arguments to DATEDIFF in the wrong order, so the signs of the difference were wrong. I've swapped them.)
 
*  ...  Using 'DATEDIFF':         ... .

numeric timedif1_2 (time13.2).
compute timedif1_2=datediff(time2, time1, "minutes").

*   The following is the same numerical value, but  .
*   with an integer display format:                 .

NUMERIC DiffMins   (F6).
COMPUTE DiffMins = timedif1_2.


*  ...   Using subtraction:       ... .

NUMERIC Subtr1_2  (time13.2).
COMPUTE Subtr1_2 = time2 - time1.

*   The following is the time value, converted to   .
*   minutes and fractions:                          .

NUMERIC Minutes (F7.3).
COMPUTE Minutes=CTIME.MINUTES(Subtr1_2).

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |25-JUN-2009 19:13:30       |
|-----------------------------|---------------------------|
      time1        time2    timedif1_2 DiffMins    Subtr1_2 Minutes

 2:19:59.99   2:23:59.99    0:00:04.00       4   0:04:00.00   4.000
 2:27:00.00   2:20:00.00   -0:00:07.00      -7  -0:07:00.00  -7.000
 1:19:45.00   3:41:16.00    0:02:21.00     141   2:21:31.00 141.517
13:14:15.25  16:17:18.50    0:03:03.00     183   3:03:03.25 183.054

Number of cases read:  4    Number of cases listed:  4

=============================
APPENDIX: Test data and code,
with thanks to Richard Oliver
=============================
data list list /time1 time2 (2time13.2).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
1:19:45    3:41:16
13:14:15.25 16:17:18.50
end data.

LIST.

*  ...  Using 'DATEDIFF':         ... .

numeric timedif1_2 (time13.2).
compute timedif1_2=datediff(time2, time1, "minutes").

*   The following is the same numerical value, but  .
*   with an integer display format:                 .

NUMERIC DiffMins   (F6).
COMPUTE DiffMins = timedif1_2.


*  ...   Using subtraction:       ... .

NUMERIC Subtr1_2  (time13.2).
COMPUTE Subtr1_2 = time2 - time1.

*   The following is the time value, converted to   .
*   minutes and fractions:                          .

NUMERIC Minutes (F7.3).
COMPUTE Minutes=CTIME.MINUTES(Subtr1_2).

LIST.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: datediff results

parisec
Richard
 
Thank you very much for going into detail on this. Date/time data has always been my nemesis and have tried to avoid it mostly because of my lack of understanding all of the formats and functions. Explanations like really help out.
 
 
Carol


From: Richard Ristow [mailto:[hidden email]]
Sent: Thursday, June 25, 2009 4:24 PM
To: Parise, Carol A.; [hidden email]
Cc: Oliver, Richard
Subject: Re: datediff results

At 02:21 PM 6/22/2009, Parise, Carol A. wrote:

I have 2 date/times and I need to compute the difference between the 2
times. I used the following syntax:

numeric TimeDif1_2 (Time10).
compute TimeDif1_2=Datediff(Time1,Time2, "minutes").


...it returned these results.

Time1      Time2       TimeDif1_2

2:19:59.99 2:23:59.99 -0:00:05
2:27:00.00 2:20:00.00  0:00:09


Notice how the TimeDif1_2 doesn't return the correct number but it's close?

Richard Oliver got this right, but I'd like to expand on it.

There are two ways to take the difference between two times (or date-times): simple subtraction (the old way), and DATEDIFF (the new way). They behave very differently:

. SPSS date-time values are in seconds, so simple subtraction gives a difference in seconds, which is a valid SPSS time value. The value should be displayed with a time format.

. DATEDIFF returns an integer, giving the (truncated) value of the difference in the units specified. It should be displayed with an F format (with no decimals).

Both the old and the new ways have their uses. In your case, you write,

I'd like the results in hh:mm:ss format so that  -0:04:00 the second one would be 0:07:00

If you want the result as a time value, use simple subtraction. Starting with input data
|-----------------------------|---------------------------|
|Output Created               |25-JUN-2009 19:13:29       |
|-----------------------------|---------------------------|
        time1         time2

   2:19:59.99    2:23:59.99
   2:27:00.00    2:20:00.00
   1:19:45.00    3:41:16.00
  13:14:15.25   16:17:18.50

Number of cases read:  4    Number of cases listed:  4

you can compare the results with DATEDIFF and with subtraction. (I think you had the time arguments to DATEDIFF in the wrong order, so the signs of the difference were wrong. I've swapped them.)
 
*  ...  Using 'DATEDIFF':         ... .

numeric timedif1_2 (time13.2).
compute timedif1_2=datediff(time2, time1, "minutes").

*   The following is the same numerical value, but  .
*   with an integer display format:                 .

NUMERIC DiffMins   (F6).
COMPUTE DiffMins = timedif1_2.


*  ...   Using subtraction:       ... .

NUMERIC Subtr1_2  (time13.2).
COMPUTE Subtr1_2 = time2 - time1.

*   The following is the time value, converted to   .
*   minutes and fractions:                          .

NUMERIC Minutes (F7.3).
COMPUTE Minutes=CTIME.MINUTES(Subtr1_2).

LIST.

List
|-----------------------------|---------------------------|
|Output Created               |25-JUN-2009 19:13:30       |
|-----------------------------|---------------------------|
      time1        time2    timedif1_2 DiffMins    Subtr1_2 Minutes

 2:19:59.99   2:23:59.99    0:00:04.00       4   0:04:00.00   4.000
 2:27:00.00   2:20:00.00   -0:00:07.00      -7  -0:07:00.00  -7.000
 1:19:45.00   3:41:16.00    0:02:21.00     141   2:21:31.00 141.517
13:14:15.25  16:17:18.50    0:03:03.00     183   3:03:03.25 183.054

Number of cases read:  4    Number of cases listed:  4

=============================
APPENDIX: Test data and code,
with thanks to Richard Oliver
=============================
data list list /time1 time2 (2time13.2).
begin data
2:19:59.99 2:23:59.99
2:27:00.00 2:20:00.00
1:19:45    3:41:16
13:14:15.25 16:17:18.50
end data.

LIST.

*  ...  Using 'DATEDIFF':         ... .

numeric timedif1_2 (time13.2).
compute timedif1_2=datediff(time2, time1, "minutes").

*   The following is the same numerical value, but  .
*   with an integer display format:                 .

NUMERIC DiffMins   (F6).
COMPUTE DiffMins = timedif1_2.


*  ...   Using subtraction:       ... .

NUMERIC Subtr1_2  (time13.2).
COMPUTE Subtr1_2 = time2 - time1.

*   The following is the time value, converted to   .
*   minutes and fractions:                          .

NUMERIC Minutes (F7.3).
COMPUTE Minutes=CTIME.MINUTES(Subtr1_2).

LIST.