* Begin with GSS93 data.
get file="y:\spss\data\gss93.sav".
* There are two variables, birthmo and cohort,. How many people
were born in January? Is that close to 1/12 of the survey
participants? Does the distribution of birth months throughout
the year look close to uniform?
What proportion and how many were born before 1960? Does the
distribution of birth years (cohort) look close to uniform?.
* In order to construct a birthdate variable we will need to assume a
day of the month for each birthdate. Assume everyone was born
on the 1st day of the month: construct birthdates for everyone!
(Hint: there are several "date construction" functions, including
date.dmy() ).
* In order to make sense of the birthdates, you will need to assign a
format to the birthday variable. What is the average birthdate for the
women in this data set? For the men? Are the maximum and minimum
the same for both groups?.
* (Harder) Suppose we decided to assign a random day of the month to
each person. Create birthdates where the day of the month varies
uniformly over {1 to 31}. Note this makes it possible to have a birthday
on Feb 31st - we'll see how SPSS handles this. How much do the
mean birthdays for men and women change?.
* Note there are no more missing values than in the previous problem! To
see what happened to the nonsensical dates, create a new variable, "a",
that has a value of Feb 31, 2011, for everyone ( a date constant). If
you look at frequencies for this variable, what date do you see?
* If you look at these date variables before you assign them formats, you
may notice that all the numbers appear to be multiples of 200. Actually
they are all multiples of 86400. Why 86400?. If you subtract 86400
from each birthday, how does it change as a date?. If you look at
the descriptives for birthday and (birthday - 86400), the answer will
be clear.
* Subtracting one month from a date is more complicated than subtracting a
day, because months vary in length. There is a function for that, datesum(). Subtract
one month from everyone's birthday using datesum(). Why is this easier than
using date.mdy() with (birthmo - 1)?.