SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
JUMMY
Obsidian | Level 7

I have a data of this form:

 

data brand;
	input preference moisturecontent sweetness @@;
	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;proc reg data=brand;model preference=moisturecontent sweetness;run;

So I used PROC REG to write out the prediction equation. How to I write a separate prediction equation between brand liking and sweetness when moisture content equals to 4 and when moisture content equals to 10? 

3 REPLIES 3
Reeza
Super User
Your code isn't correct. you can't have 'BY MAKE' since you have no make variable.

It's not quite clear what you question is, can you please clarify in detail?
JUMMY
Obsidian | Level 7

@Reeza, I apologize for the mistake. I have corrected it. PROC REG gives the multiple regression line for the data. But I want to come up with two different equations for preference and sweetness when moisture content equals to 4 and when moisture content equals to 10.

Reeza
Super User

@JUMMY wrote:

@Reeza, I apologize for the mistake. I have corrected it. PROC REG gives the multiple regression line for the data. But I want to come up with two different equations for preference and sweetness when moisture content equals to 4 and when moisture content equals to 10.



Put that variable in the BY statement too. The BY statement can take multiple variables and will do it by nested groups. 

 

By make sweetness;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 839 views
  • 0 likes
  • 2 in conversation