/* SAS Example 7: Textbook Second Edition Q11.33 Page 514 */ /* Safety in motels and hotels is a growing concern among travelers. Suppose a survey was conducted by the National Motel and Hotel Association to determine the US traveler's perception of safety in various motel chains. The association chose four different national chains from the economy lodging sector and randomly selected 10 people who had stayed overnight in a motel in each of the four chains in the past 2 years. Each selected traveler was asked to rate each motel chain on a scale from 0 to 100 to indicate how safe he or she felt at that motel. A score of zero indicates completely unsafe and a score of 100 indicates perfectly safe. The scores follow. Test this randomized block design to determine whether there is a significant difference in the safety ratings of the four motels. Use alpha = .05 */ OPTIONS PS=60; OPTIONS LS=78; OPTIONS NODATE; OPTIONS PAGENO=1; /* In the next command I am naming the text file on drive a: (called motel.prn) HOTEL6, just for easy reference throughout the rest of the program */ FILENAME HOTEL6 'a:/motel.prn'; /* The infile statement in the following data step will take the hotel6 file that we named earlier. This infile statement is useful if we are dealing with large data files that we have in other formats. */ DATA MOTEL; INFILE HOTEL6; INPUT TRAVELER MOTEL RATING; RUN; PROC PRINT DATA=MOTEL; TITLE 'Motel Safety Rating Data'; RUN; /* The GPLOT procedure will produce a graphic plot. The plot command asks for a plot of rating against traveler (in case 1), and this is all we are required to ask for - however, by putting the "=motel" part in the formula it will label all points for motel 1 with one color, all points for motel 2 in another color, etc. The join command will then join all points that share a motel together. */ PROC GPLOT DATA=MOTEL; PLOT RATING*TRAVELER=MOTEL/ FRAME; SYMBOL1 VALUE=DOT I=JOIN; TITLE1 'Plot of Rating versus Traveler'; TITLE2 'Points joined by a line represent the same motel'; RUN; PROC GPLOT DATA=MOTEL; PLOT RATING*MOTEL=TRAVELER/ FRAME; SYMBOL1 VALUE=DOT I=JOIN; TITLE1 'Plot of Rating versus Motel'; TITLE2 'Points joined by a line represent the same traveler'; RUN; /* Since we have a balanced design, we may wish to use PROC ANOVA to analyze the data. We set up our model in the same way as we did with PROC GLM, ie. Model "dependent variable" = "explanatory variables" while we state our explanatory (classification) variables in the CLASS statement. */ PROC ANOVA DATA=MOTEL; CLASS MOTEL TRAVELER; MODEL RATING = MOTEL TRAVELER; RUN;