27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Date and Time<br />

SPSS reads and writes date and time in many different formats but stores them as floatingpoint<br />

numbers. You can perform arithmetic operations on them, use them in statistical<br />

procedures, and display or print them in a format of your choice. This section discusses the<br />

input and output formats for date and time, arithmetic operations using date and time<br />

variables, and date and time functions.<br />

Date and Time Formats<br />

Date and time formats are both input and output formats. They can be used on DATA LIST and<br />

other variable definition commands to read in values representing dates or times or date-time<br />

combinations. Like numeric formats, each input format generates a default output format,<br />

automatically expanded (if necessary) to accommodate display width. In addition, you can<br />

assign or modify output formats using FORMATS, WRITE FORMATS, and PRINT FORMATS<br />

commands. The output formats are effective only with LIST, REPORT, and TABLES procedures<br />

and the PRINT and WRITE transformation commands. Other procedures use the F format and<br />

display the values as numbers.<br />

• All date and time formats have a minimum input width, and some have a different<br />

minimum output. Wherever the input minimum width is less than the output minimum,<br />

SPSS expands the width automatically when displaying or printing values. However,<br />

when you specify output formats, you must allow enough space for displaying the date<br />

and time in the format you choose.<br />

• Input data shorter than the specified width are correctly evaluated as long as all the<br />

necessary elements are present. For example, with the TIME format, 1:2, 01 2, and 01:02<br />

are all correctly evaluated even though the minimum width is 5. However, if only one<br />

element (hours or minutes) is present, you must use a time function to aggregate or<br />

convert the data (see “Date and Time Functions” on p. 62).<br />

• If a date or time value cannot be completely displayed in the specified width, values are<br />

truncated in the output. For example, an input time value of 1:20:59 (1 hour, 20 minutes,<br />

59 seconds) displayed with a width of 5 will generate an output value of 01:20, not<br />

01:21. The truncation of output does not affect the numeric value stored in the working<br />

file.<br />

Table 7 shows all available date and time formats, where w indicates the total number of<br />

columns and d (if present), the number of decimal places for fractional seconds. The<br />

example shows the output format with the minimum width and default decimal positions (if<br />

applicable). The format allowed in the input data is much less restrictive (see “Input Data<br />

Specification” on p. 57).<br />

55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!