|
I need to compare one date-time to another date-time in minutes, but my
date and time variables are in different fields. Is it possible to combine the two? I tried using the date and time wizard, but that only allows the combination of numeric variables, and my date variable is already in date format, and my time variable is in strong format and can be converted to date format, but not, it appears, to numeric format. I realize the long way around this is to compare dates, and if dates are the same, then compare times. But this might get messy when I need to compare times from two different dates. I would prefer to combine date and time into a single variable, if possible. Any ideas? Alan Alan D. Krinsky PhD, MPH Manager, Medical Management Interventions UMass Memorial Health Care Worcester, MA 01605 alan.krinskyATumassmemorial.org The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ====================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 |
|
At 02:32 PM 12/16/2008, Krinsky, Alan wrote:
>I need to compare one date-time to another date-time in minutes, but >my date and time variables are in different fields. Is it possible >to combine the two? I tried using the date and time wizard, but that >only allows the combination of numeric variables, and my date >variable is already in date format, and my time variable is in >string format and can be converted to date format, but not, it >appears, to numeric format. I'm not sure what the wizard will do, but such variables are easy to combine in syntax. Date and time variables *are* numeric. If 'Date' is an SPSS date variable, and 'TimeofDy' a time variable, then the date-time is their sum: COMPUTE DateTime = Date + TimeofDy. FORMATS DateTime (DATETIME17). See if this works. If not, post the syntax that the wizard generates, and a little test data. -Best of luck, Richard ===================== 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 |
|
In reply to this post by Krinsky, Alan-2
data list list /datevar (adate10) timevar (a5).
begin data 10/28/2008 15:30 end data. compute datetimevar= datevar + number(timevar, time5). formats datetimevar (datetime20). list. Note that this solution assumes that times are recorded in 24-hour clock time style. If times are recorded in am/pm style, the code would be a tad more complicated, the degree of complication depending on whether the am/pm information is contained in the same string as the time or in a different string. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Krinsky, Alan Sent: Tuesday, December 16, 2008 1:33 PM To: [hidden email] Subject: Combining date and time from two variables into one I need to compare one date-time to another date-time in minutes, but my date and time variables are in different fields. Is it possible to combine the two? I tried using the date and time wizard, but that only allows the combination of numeric variables, and my date variable is already in date format, and my time variable is in strong format and can be converted to date format, but not, it appears, to numeric format. I realize the long way around this is to compare dates, and if dates are the same, then compare times. But this might get messy when I need to compare times from two different dates. I would prefer to combine date and time into a single variable, if possible. Any ideas? Alan Alan D. Krinsky PhD, MPH Manager, Medical Management Interventions UMass Memorial Health Care Worcester, MA 01605 alan.krinskyATumassmemorial.org The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ======= 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 |
| Free forum by Nabble | Edit this page |
