The script begins by creating a 'detergent' dataset from internal data (datalines), representing the results of a brand preference survey. Then, it uses PROC CATMOD to fit two statistical models. The first is a saturated model including all interactions between explanatory variables (water type, prior use, temperature) to predict the preferred brand. The second is a simpler model, considering only the main effects of these same variables, to compare the adjustments.
Data Analysis
Type : INTERNAL_CREATION
Data is created directly within the script via a DATA STEP and a DATALINES statement. It represents an aggregated contingency table where the 'Count' variable serves as a weight.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block reads survey data directly from the code (datalines). The variables Softness, Brand, Previous, Temperature, and Count are read. The '@@' option on the INPUT statement indicates that multiple observations can be on the same data line.
Copied!
data detergent;
input Softness $ Brand $ Previous $ Temperature $ Count @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
datalines;
soft X yes high 19 soft X yes low 57
soft X no high 29 soft X no low 63
soft M yes high 29 soft M yes low 49
soft M no high 27 soft M no low 53
med X yes high 23 med X yes low 47
med X no high 33 med X no low 66
med M yes high 47 med M yes low 55
med M no high 23 med M no low 50
hard X yes high 24 hard X yes low 37
hard X no high 42 hard X no low 68
hard M yes high 43 hard M yes low 52
hard M no high 30 hard M no low 42
;
Explanation : This procedure analyzes categorical data. 'WEIGHT Count' specifies that the data is aggregated. 'RESPONSE 1 0' defines the response function. A first saturated model (complete model with all interactions: Softness|Previous|Temperature) is fitted. Then, a simpler second model, with only the main effects, is tested to compare the results. The options '/freq prob' request the display of frequencies and probabilities, and '/clparm noprofile design' request confidence intervals for parameters as well as the model design matrix.
Copied!
title 'Detergent Preference Study';
proc catmod data=detergent;
response 1 0;
weight Count;
model Brand=Softness|Previous|Temperature / freq prob;
title2 'Saturated Model';
run;
model Brand=Softness Previous Temperature
/ clparm noprofile design;
title2 'Main-Effects Model';
run;
quit;
1
title 'Detergent Preference Study';
2
PROC CATMODDATA=detergent;
3
response 1 0;
4
weight Count;
5
model Brand=Softness|Previous|Temperature / freq prob;
6
title2 'Saturated Model';
7
RUN;
8
9
model Brand=Softness Previous Temperature
10
/ clparm noprofile design;
11
title2 'Main-Effects Model';
12
RUN;
13
QUIT;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.