Longitudinal trends in the PSID

Here we take a brief look at the longitudinal trends for log(Wages) classified by some of the demographic variables.

All the commands below are stored in the file R:\psych\spida\courses\eda\psidex2.sas. You can include them directly into SAS by typing in the Editor window:

%include spidaeda(psidex2);
or, you can copy/paste from this window into the SAS Editor window. But, hey, you should know this by now!

First of all, we copy the data to a new dataset called PSID, located in the temporary work folder and is retrieved from the original dataset called PSID.PSID in the R drive.

title 'PSIDEX2: Longitudinal trends in the PSID';
*-- Make a working copy of the PSID data;
data psid;
   set psid.psid;
   run;

Summary statistics

To compare the time trends over time for different groups, we use PROC SUMMARY with the NWAY option to get the mean (and standard error) for each of the combinations of FEM * SOUTH * BLK.

*-- Get means for dichotomous variables;
proc summary data=psid nway;
   class fem south blk t;
   var lwage;
   output out=means mean=lwage stderr=stderr;
   run;

Plotting the means over time

The simplest plot shows the means for each of the 2 x 2 x 2 combinations of FEM * SOUTH * BLK. To do this plot with SAS, you must create a new variable, group which makes the 8 combinations of FEM * SOUTH * BLK into a single variable.

*- Combine labels for groups: Needed to plot
   lWage * t = group in one plot;

data means;
   set means;
   drop _type_;
   length group $20;
   if fem=1   then group='Fem'; else group='Mal';
   if south=1 then group=trim(group) || 'Sou'; else group=trim(group) || 'Nor';
   if blk  =1 then group=trim(group) || 'Blk'; else group=trim(group) || 'Whi';
proc print;
    id group;
   var lwage stderr;
   run;
OK, now we can make the plot. We use SYMBOL statements to identity each combination of FEM * SOUTH * BLK with a different symbol and color combination.
*-- Plot means over time for each group;
goptions reset=symbol;
proc gplot data=means;
   plot lwage * t = group /
      vaxis=axis1 haxis=axis2 hminor=0 vminor=1;

   axis1 label=(a=90 r=0);
   axis2 offset=(3);

   symbol1 v=square c=black i=join;
   symbol2 v=dot    c=black i=join;
   symbol3 v=square c=blue  i=join;
   symbol4 v=dot    c=blue  i=join;
   symbol5 v=square c=red   i=join;
   symbol6 v=dot    c=red   i=join;
   symbol7 v=square c=green i=join;
   symbol8 v=dot    c=green i=join;
run;