BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MadQuidd
Obsidian | Level 7

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.
1 ACCEPTED SOLUTION

Accepted Solutions
SAS_inquisitive
Lapis Lazuli | Level 10
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

3 REPLIES 3
SAS_inquisitive
Lapis Lazuli | Level 10
You probably might want post this question under SAS procedures where you can find experts in Proc Glm, Proc Mixed, Proc Glimmix etc.
FreelanceReinh
Jade | Level 19

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.

Rick_SAS
SAS Super FREQ

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3099 views
  • 3 likes
  • 4 in conversation