SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JUMMY
Obsidian | Level 7

I need help with fitting a full quadratic model using PROC REG that contains two linear terms (sweetness and moisturecontent), two quadratic terms (sweetness^2 and moisturecontent^2) and the interaction term for the data below.

 

data brand;
	input preference moisturecontent sweetness @@;
	if sweetness=2 then dummy=1;
    else if sweetness=4 then dummy=0;
  		dummy_moisture=dummy*moisturecontent;
	datalines;
	64 4 2 73 4 4 61 4 2 76 4 4 72 6 2 80 6 4 
	71 6 2 83 6 4 83 8 2 89 8 4 86 8 2 93 8 4
	88 10 2 95 10 4 94 10 2 100 10 4
	;
run;
proc print;
run;

Please use ONLY PROC REG in explaining.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Your last line makes me wonder whether this is for a class? If so, you should say so. It enables the experts to give you hints and suggestions that can lead you towards the answer, instead of solving the problem for you.

 

You can use the GLMMOD procedure to generate the design matrix that contains the dummy variables

 

proc glmmod data=brand outdesign=Design;
model preference = moisturecontent sweetness 
                   moisturecontent*moisturecontent
                   moisturecontent*sweetness 
                   sweetness*sweetness;
run;

The columns od the DESIGN data set contain the dummy variables, which you can then use in PROC REG:

 

proc reg data=Design;
model preference = col2-Col6;
quit;

In spite of your admonition to "ONLY [use] PROC REG in explaining," I feel compelled to point out that it is much easier to use PROC GLM and the CLASS statement:

 

proc glm data=brand ;
model preference = moisturecontent sweetness 
                   moisturecontent*moisturecontent
                   moisturecontent*sweetness 
                   sweetness*sweetness;
run;

ContourFit.gif 

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@JUMMY wrote:

 

Please use ONLY PROC REG in explaining.


I object to this restriction. You are only making life harder for yourself.

 

So, for anyone else reading along, this should work:

 

proc glm data=have;
    class sweetness;
    model preference = sweetness | moisturecontent moisturecontent*moisturecontent;
run;
quit;
--
Paige Miller
JUMMY
Obsidian | Level 7

@PaigeMiller, I need the diagnostic plots. GLM doesn't help in writing out an equation. There are no coefficients to use in deriving or fitting my model. Thats why I opted for PROC REG please.

Rick_SAS
SAS Super FREQ

Your last line makes me wonder whether this is for a class? If so, you should say so. It enables the experts to give you hints and suggestions that can lead you towards the answer, instead of solving the problem for you.

 

You can use the GLMMOD procedure to generate the design matrix that contains the dummy variables

 

proc glmmod data=brand outdesign=Design;
model preference = moisturecontent sweetness 
                   moisturecontent*moisturecontent
                   moisturecontent*sweetness 
                   sweetness*sweetness;
run;

The columns od the DESIGN data set contain the dummy variables, which you can then use in PROC REG:

 

proc reg data=Design;
model preference = col2-Col6;
quit;

In spite of your admonition to "ONLY [use] PROC REG in explaining," I feel compelled to point out that it is much easier to use PROC GLM and the CLASS statement:

 

proc glm data=brand ;
model preference = moisturecontent sweetness 
                   moisturecontent*moisturecontent
                   moisturecontent*sweetness 
                   sweetness*sweetness;
run;

ContourFit.gif 

JUMMY
Obsidian | Level 7
@Rick_SAS, I feel honored to have you comment on my post. Thank you so much for taking time to explain this to me.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 4 replies
  • 1431 views
  • 2 likes
  • 3 in conversation