Data visualization with SAS programming

interaction plot

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

interaction plot

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.

 

Data drunk;
length region $ 11;
input Region $ Male Female;
datalines;
Eastern 24.17 42.33
Norther 51.00 51.00
Continental 24.33 33.17
;
run;
Proc print data=drunk;
run;

 

proc glm data=drunk;
CLASS male female;
model region = male female male*female;
means male female/lsd cldiff;
Run;

 

ERROR: Variable region in list does not match type prescribed for this list.
NOTE: The previous statement has been deleted.
59 lsmeans male female / pdiff=all adjust=tukey;
ERROR: Effects used in the LSMEANS statement must have appeared previously in the MODEL statement.

Accepted Solutions
Solution
‎04-14-2016 04:41 PM
Regular Contributor
Posts: 193

Re: interaction plot

You probably might want post this question under SAS procedures where you can find experts in Proc Glm, Proc Mixed, Proc Glimmix etc.

View solution in original post


All Replies
Solution
‎04-14-2016 04:41 PM
Regular Contributor
Posts: 193

Re: interaction plot

You probably might want post this question under SAS procedures where you can find experts in Proc Glm, Proc Mixed, Proc Glimmix etc.
Trusted Advisor
Posts: 1,114

Re: interaction plot

Hi @MadQuidd,

 

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.

SAS Super FREQ
Posts: 3,222

Re: interaction plot

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.

Post a Question
Discussion Stats
  • 3 replies
  • 551 views
  • 3 likes
  • 4 in conversation