02-26-2016 03:02 PM
I am trying to do an interaction plot with my data but keep recieving errors. I dont know whether it is a problem with how my data is structured or the code I am using. An exampe of the code is below as well as the error code I received.
length region $ 11;
input Region $ Male Female;
Eastern 24.17 42.33
Norther 51.00 51.00
Continental 24.33 33.17
Proc print data=drunk;
proc glm data=drunk;
CLASS male female;
model region = male female male*female;
means male female/lsd cldiff;
02-28-2016 10:42 AM
The first error message is fairly explicit: It says that variable REGION does not have the appropriate type. Since there are only two types of variables in SAS, character and numeric, and REGION is undoubtedly character, SAS wants it to be numeric. The reason becomes clear when you look at the Statistical Assumptions for Using PROC GLM.
The second error message is merely a consequence of the fact that the MODEL statement has been deleted (see the "NOTE" in the log) due to the invalid type of variable REGION, so that a subsequent LSMEANS or MEANS statement has no basis.
Moreover, you have specified MALE and FEMALE as CLASS variables. That is, MALE and FEMALE should be discrete variables taking only a couple of different values. The values in your dataset, however, suggest that MALE and FEMALE are continuous variables. I could imagine that the numbers 24.17 etc. are either (mean?) values of a third variable, possibly the actual dependent variable of your model, or percentages. It might make more sense to restructure the data in such a way that there is a variable SEX, e.g., with values "M" and "F" (this would be a typical candidate for a CLASS variable, as would REGION) and a different variable containing the numeric values 24.17 etc. Maybe you want to visualize the interaction between SEX and REGION? The target variable (having the numeric values) should be the one on the left side of the equals sign. Please see Example 46.3 Unbalanced ANOVA for Two-Way Design with Interaction of the documentation of PROC GLM for a worked example of how to create an interaction plot in this situation.
Generally, before starting to code, you should write down the research question, determine the appropriate statistical method(s) and then find out which SAS procedure(s) support this type of analysis. The analysis dataset will then have to be prepared according to the requirements of the procedure.
02-29-2016 08:26 AM
If you are trying to predict a categorical response, you can't use PROC GLM. For many research questions you can use PROC LOGISTIC or PROC GENMOD. Since the response variable seems to be nominal, I suggest you look at the example in the PROC LOGISTIC doc that uses a generalized logit model to fit nominal response data.