Dear Listers,
I have reviewed the archives and visited Raynald's www.spsstool.net <http://www.spsstool.net/> website to find elapsed time syntax. I did find the syntax from (http://www.spsstools.net/Syntax/DatesTime/CaculateNumberOfMinutes.txt) to be helpful and almost what I need. The format of my data is different in that it has the semicolon in the time and I am not sure how to change the syntax to fit my data. Sample of my data 1 20:05 22:40 2 . . 3 2:15 6:40 4 19:34 23:05 5 . 10:05 6 . 6:12 7 16:10 17:45 8 7:35 11:57 9 3:22 7:07 10 19:47 23:37 11 . 12:55 12 22:00 1:07 13 18:55 20:25 14 10:20 13:37 15 15:20 19:38 16 9:06 12:27 17 0:45 2:55 18 16:30 18:28 19 13:35 14:05 20 9:35 . 21 5:54 9:18 I would appreciate any additional help on the elapsed time calculation. Shannon Deike-Sims [hidden email] |
Try this:
Suppose t1 and t2 are the original VARIABLES : STRING st1 st2 (A6). COMPUTE st1=REPLACE(t1,":",""). COMPUTE st2=REPLACE(t2,":",""). COMPUTE time1=number(st1,f6.0). COMPUTE time2=number(st2,f6.0). EXECUTE. Sample Data t1 t2 16:10 10:20 7:35 15:20 3:22 1:20 Output. t1 t2 st1 st2 time1 time2 16:10 10:20 1610 1020 1610.00 1020.00 7:35 15:20 735 1520 735.00 1520.00 3:22 1:20 322 120 322.00 120.00 There could be a simpler way of doing this . Regards. Edward -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Shannon Deike-Sims Sent: Friday, August 04, 2006 3:37 PM To: [hidden email] Subject: Elapsed Time Calculation Dear Listers, I have reviewed the archives and visited Raynald's www.spsstool.net <http://www.spsstool.net/> website to find elapsed time syntax. I did find the syntax from (http://www.spsstools.net/Syntax/DatesTime/CaculateNumberOfMinutes.txt) to be helpful and almost what I need. The format of my data is different in that it has the semicolon in the time and I am not sure how to change the syntax to fit my data. Sample of my data 1 20:05 22:40 2 . . 3 2:15 6:40 4 19:34 23:05 5 . 10:05 6 . 6:12 7 16:10 17:45 8 7:35 11:57 9 3:22 7:07 10 19:47 23:37 11 . 12:55 12 22:00 1:07 13 18:55 20:25 14 10:20 13:37 15 15:20 19:38 16 9:06 12:27 17 0:45 2:55 18 16:30 18:28 19 13:35 14:05 20 9:35 . 21 5:54 9:18 I would appreciate any additional help on the elapsed time calculation. Shannon Deike-Sims [hidden email] |
In reply to this post by Shannon Deike-Sims
Shannon,
From your description you must mean that your time data looks like 1 20;05 22;40 2 . . 3 2;15 6;40 And not 1 20:05 22:40 2 . . 3 2:15 6:40 I can think of a couple of ways to do this and there may be others. One method is to read the times in as STRINGs, extract the hours and minutes as separate numeric variables and then recombine them into a time value. The other method is to again read the data in as STRINGs, do a locate and replace of the semicolin with a colon, write the data back out to a text file and then read that file back in using time formats. I think there's more opportunities for cleverness, if that appeals to you, in the first method. It's Friday, so I'll do the second method. I'll assume that you can set up the Data list statement or text data wizard to get the data in. Then, (let T1 and T2 be the two time variables as read and T1m and T2m be the modified values. Do repeat x=T1 T2/y=T1m T2m. + Compute #loc=index(x,';'). + Compute substr(x,#loc,1)=':'. End repeat. I'll assume you can set up the syntax to write out the corrected variables (plus any others). Gene Maguin |
In reply to this post by Shannon Deike-Sims
The first syntax was too convoluted .
If t1 and t2 and the original 2 time variables, you can convert you data to the required format using the syntax below. You can then proceed to use Raynald's syntax. COMPUTE time1=NUMBER(REPLACE(t1,":",""),F6.00) . COMPUTE time2=NUMBER(REPLACE(t2,":",""),F6.0) . EXECUTE. Have a nice weekend. Regards. Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Shannon Deike-Sims Sent: Friday, August 04, 2006 3:37 PM To: [hidden email] Subject: Elapsed Time Calculation Dear Listers, I have reviewed the archives and visited Raynald's www.spsstool.net <http://www.spsstool.net/> website to find elapsed time syntax. I did find the syntax from (http://www.spsstools.net/Syntax/DatesTime/CaculateNumberOfMinutes.txt) to be helpful and almost what I need. The format of my data is different in that it has the semicolon in the time and I am not sure how to change the syntax to fit my data. Sample of my data 1 20:05 22:40 2 . . 3 2:15 6:40 4 19:34 23:05 5 . 10:05 6 . 6:12 7 16:10 17:45 8 7:35 11:57 9 3:22 7:07 10 19:47 23:37 11 . 12:55 12 22:00 1:07 13 18:55 20:25 14 10:20 13:37 15 15:20 19:38 16 9:06 12:27 17 0:45 2:55 18 16:30 18:28 19 13:35 14:05 20 9:35 . 21 5:54 9:18 I would appreciate any additional help on the elapsed time calculation. Shannon Deike-Sims [hidden email] |
Free forum by Nabble | Edit this page |