/* SAS Example 8: Textbook Second Edition Q11.43 Page 531 */
/* Children are generally believed to have considerable influence
over their parents in the purchase of certain items, particularly
food and beverage items. To study this notion further, a study is
conducted in which parents are asked to report how many food and
beverage items purchased by the family per week are purchased
mainly because of the influence of their children. Because the age
of the child may have an effect on the study, parents are asked to
focus on one particular child in the family for the week, and to
report the age of the child. Four age categories are selected for
the children: 4-5 years, 6-7 years, 8-9 years and 10-12 years.
Also, because the number of children in the family might make a
difference, three different sizes of family are chosen for the
study: families with one child, families with two children and
families with three or more children. Suppose the following data
represent the reported number of child-influenced parent buying
incidents per week. Use the data to compute a two-way ANOVA. Let
alpha=.05. */
OPTIONS PS=52;
OPTIONS LS=78;
OPTIONS NODATE;
OPTIONS PAGENO=1;
/* Since the format of the data is strange it will be best to save it
as a space delimited text file, when converting it from Excel or
SPSS */
FILENAME CHILD 'a:/children.prn';
DATA CHILDREN;
INFILE CHILD;
INPUT AGE $1-7 CHILDREN $8-14 PURCHASES;
RUN;
PROC PRINT DATA=CHILDREN;
TITLE 'Child-Influenced Parent Buying Data';
RUN;
PROC SORT DATA=CHILDREN;
BY AGE CHILDREN;
RUN;
/* The age*children term in our model requests an interaction effect */
PROC GLM DATA=CHILDREN;
CLASS AGE CHILDREN;
MODEL PURCHASES = AGE CHILDREN AGE*CHILDREN;
/* To compare children 7 and under to those 8 and over */
CONTRAST 'Before and after 8th birthday' AGE 1 -1 -1 1;
/* To compare 1-child families with multi-child families */
CONTRAST 'One-child vs multi-child' CHILDREN 2 -1 -1;
LSMEANS AGE CHILDREN AGE*CHILDREN;
RUN;
/* If we wish to print a profile plot, we first need to run proc
means and save the value of the means in an outfile. This will
allow us to plot the means in a later stage. */
PROC MEANS DATA=CHILDREN;
BY AGE CHILDREN;
VAR PURCHASES;
OUTPUT OUT=PURMEANS MEAN=PURMEAN;
RUN;
/* Here we will use the means and plot them in a profile plot */
PROC GPLOT DATA=PURMEANS;
PLOT PURMEAN*CHILDREN=AGE/ FRAME;
SYMBOL1 VALUE=DOT I=JOIN;
TITLE1 'Plot of Purchases versus Number of Children';
TITLE2 'Points joined by a line represent children of the same age group';
RUN;