Dates and times


StatsDirect accepts date and time entries in its workbooks. When you enter say 1/3/67 it will be recognised as the first of March 1967. This is then stored as a code by the workbook. If you were to enter 1/3/67 10:00 then the code stored would have an integer part which represents the date and a decimal part which represents the time, here 10 AM.


You may enter years as a two or four code number. If you enter a two figure date from 00 to 29 then it will be interpreted as 2000 to 2029, all other two figure dates are treated as 19XX.


A column of dates can be treated as a column of date codes and analysed in the way you would treat, say Julian numbers. If you ask for descriptive statistics on a column of date entries then you will get the descriptive statistics of the date codes. The difference between two date codes represents the number of days between the dates and any fractional part would represent the number of seconds between the two entries.


The simplest way to handle dates is to let StatsDirect transform then into intervals. For example, say you started a study on day X and recorded the dates when a particular event happened to any of the study subjects. If no event happened to a study subject then you could enter the date the study finished, and in a separate column enter a censorship code of 0 to denote no event. Then use the "Date & Time" interval function in the "Data" menu to work out the number of days, weeks, months etc which elapsed between the start of the study and the event time or ending time. The intervals can be used for survival analysis.


You may also use the workbook to handle date or time intervals. Say you had one column of starting dates (column A) and one column of finishing dates (column B) in a workbook. In the first row of column C enter =A1-A2 and move your mouse to the bottom right hand corner of the C1 cell. The mouse cursor will change to a fine cross at this point and you can now drag the first cell of column C down until you reach the bottom of the A and B columns. Now column C will represent all of the differences in days between A and B. If you want the difference in weeks then you would enter =TRUNC((A1-A2)/7) as the first expression, or for months =TRUNC((A1/A2)/(365/12)) and =TRUNC((A1/A2)/365) for years. The TRUNC function is used here to truncate any fractional part of a result to an integer, see workbook functions for more details.