IBM SPSS defines each variable with a “TYPE”. By default, all variables in SPSS are assumed to be numeric until you change them. SPSS V20 currently supports the following variable types:
- Numeric and String (the most common),
- Comma,
- Dot,
- Scientific Notation,
- Date,
- Dollar,
- Custom Currency and
- Restricted Numeric
Today I want to focus on “Date” variables which are generally termed “Date/Time variables” (for those of you “old schools”, you might know these variables as “date-format variables”).
It is also important to know that these variables can be divided into (1) those that actually represent dates and (2) those that are used to hold time durations.
In IBM SPSS, both kinds of date variables are actually numeric values with assigned display formats. The first, (those that represent actual dates) use a format such as:
MM/DD/YYYY
While the second kind (those that represent a date and time), use a format such as:
DD-MMMM-YYYY: MM:SS
I won’t go into detail on the formatting possibilities here (that’s what the help file is for!) but below are some exerts:
- Both two- and four-digit year specifications are recognized.
- Dashes, periods, commas, slashes, or blanks can be used as delimiters in day-month-year formats.
- Months can be represented in digits, Roman numerals, or three-character abbreviations and they can be fully spelled out.
- In time specifications (applies to date/time and duration variables), colons can be used as delimiters between hours, minutes, and seconds. Hours and minutes are required, but seconds are optional. A period is required to separate seconds from fractional seconds.
- The system variable $TIME holds the current date and time. It represents the number of seconds from October 14, 1582, to the date and time when the transformation command that uses it is executed.
SPSS thoughtfully supplies us with a “Date and Time Wizard” meant to simplify our life when performing a number of common chores associated with our date and time variables.
To access this wizard, you can click on Transform (in the Statistics Viewer) and then
select Date and Time Wizard…
From the “Date and Time Wizard” dialog you can select the following options:
- Learn how dates and times are represented. This choice leads to a screen that provides a brief overview of date/time variables in SPSS -in case you were too lazy to just go to help :).
- Create a date/time variable from a string containing a date or time. Use this option to create a date/time variable from a string variable in your current dataset. I use this one a lot (no programing required!). The wizard shows you all the string variables in your current data file, the value of each and gives you the ability to select the exact formatting you want to use for the new variable.
- Create a date/time variable from variables holding parts of dates or times. This choice allows you to construct a date/time variable from a set of existing variables. Again, very useful. If your data file has date and time information in separated variables, for example year month and day all being separate – you can use this wizard option to “paste” them together in one nicely formatted variable field.
- Calculate with dates and times. Use this option to add or subtract values from date/time variables. Again, no programming involved – you can add or subtract a “duration amount” from a date or date/time variable or even compute the total time units between two dates.
- Extract a part of a date or time variable. This option allows you to extract part of a date/time variable, such as the day of the month from a date/time variable, which has the form mm/dd/yyyy. Kind of cool – you can use this option to make a new variable from any “part” of an existing date or time variable.
- Assign periodicity to a dataset. This choice takes you to the Define Dates dialog box, used to create date/time variables that consist of a set of sequential dates. This option is a little more interesting – you can use it to create new date or time “sequential” or “date association” variables.
Until next time,
JDM
“Ah, then it’s a gift.”
Doctor Zhivago (1965)
Simply wanna input that you have a very decent website , I like the style it really stands out.