Example: Analyzing Age and Gender

  1. In SAS Studio, click New Options Icon and select New SAS Program.
  2. Create the Pr data set by copying and pasting this code into the Program tab:
    data pr;
    input Person Gender $ y1 y2 y3 y4;
    y=y1; Age=8; output;
    y=y2; Age=10; output;
    y=y3; Age=12; output;
    y=y4; Age=14; output;
    drop y1-y4;
    datalines;
    1 F 21.0 20.0 21.5 23.0
    2 F 21.0 21.5 24.0 25.5
    3 F 20.5 24.0 24.5 26.0
    4 F 23.5 24.5 25.0 26.5
    5 F 21.5 23.0 22.5 23.5
    6 F 20.0 21.0 21.0 22.5
    7 F 21.5 22.5 23.0 25.0
    8 F 23.0 23.0 23.5 24.0
    9 F 20.0 21.0 22.0 21.5
    10 F 16.5 19.0 19.0 19.5
    11 F 24.5 25.0 28.0 28.0
    12 M 26.0 25.0 29.0 31.0
    13 M 21.5 22.5 23.0 26.5
    14 M 23.0 22.5 24.0 27.5
    15 M 25.5 27.5 26.5 27.0
    16 M 20.0 23.5 22.5 26.0
    17 M 24.5 25.5 27.0 28.5
    18 M 22.0 22.0 24.5 26.5
    19 M 24.0 21.5 24.5 25.5
    20 M 23.0 20.5 31.0 26.0
    21 M 27.5 28.0 31.0 31.5
    22 M 23.0 23.0 23.5 25.0
    23 M 21.5 23.5 24.0 28.0
    24 M 17.0 24.5 26.0 29.5
    25 M 22.5 25.5 25.5 26.0
    26 M 23.0 24.5 26.0 30.0
    27 M 22.0 21.5 23.5 25.0
    ;
    Click Submit SAS Code Icon to create the Work.Pr data set.
  3. In the Tasks section, expand the Statistics folder, and then double-click Mixed Models. The user interface for the Mixed Models task opens.
  4. On the Data tab, select the WORK.PR data set.
    Tip
    If the data set is not available from the drop-down list, click Select a table icon. In the Choose a Table window, expand the library that contains the data set that you want to use. Select the data set for the example and click OK. The selected data set should now appear in the drop-down list.
  5. Assign columns to these roles:
    Role
    Column Name
    Dependent variable
    y
    Classification variables
    Person
    Gender
    Continuous variables
    Age
  6. Create a two-way factorial fixed effect.
    1. On the Model tab, click Edit Icon to create a fixed effect. The Fixed Effects Builder opens.
    2. In the Variables pane, select Gender and Age. Click Two-way Factorial.
    3. Click OK to close the Fixed Effects Builder.
    Here is the result on the Model tab:
    Fixed Effects —Intercept, Age, Gender, and Age*Gender
  7. Create a repeated subject effect.
    1. On the Model tab, click Add Repeated Effect Icon to add a repeated effect.
    2. Under the Repeated Effect heading, click Edit Icon. The Repeated Effects Builder opens.
    3. In the Repeated Effects Builder, select the radio button for Subject effect. In the Variables pane, select Person, and then click Add.
    4. Under the subject effect, click Covariance Structures. The Select Covariance Structures window appears.
    5. From the drop-down list, select Unstructured and click OK to return to the Repeated Effects Builder.
    6. Click OK to close the Repeated Effects Builder.
    Here is the result on the Model tab:
    Repeated Effects Showing Person as Subject Effect and with Unstructured as the Covariance Structures
  8. On the Options tab:
    • In the Estimated method drop-down list, select Maximum likelihood.
    • In the Select statistics to display drop-down list, select Default and additional statistics.
      • Expand the Tests heading, and select Standard errors and Wald Test of covariance parameters.
      • Expand the Parameter Estimates heading. Under the Fixed Effects heading, select Show parameter estimates. Under the Repeated Effect heading, select Estimated R matrix.
  9. To run the task, click Submit SAS Code Icon.
Here is a subset of the results:
Model Information, Class Level Information, and Dimensions Tables
Iteration History, Estimated R Matrix for Person 1, and Covariance Parameter Estimates