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

Hi,

I have this model but I want to make a regression model for each specific hour,

proc reg data=dataname(where=(Month in(6,7,8)));
model Load=Temperature;
label Load="Load (MW)" Temperature="Temperature";
title 'Load vs Temp (Summer)';
run;

How can I include where=(Hour in(1)) or where=(Hour in(22)) etc. I tried 

(where=(Month in(6,7,8))(Hour in(1)))

but it didn't work

 

Also what can I do when I only want a model where Temperature is Between 55 and 65?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

if you want two or more conditions in a where clause use AND

  (where=(Month in(6,7,8) and Hour in(1)) )

same with temperature

 

and   55 le temperature le 65

 

And "Didn't work" is awful vague. Since the syntax you show

(where=(Month in(6,7,8))(Hour in(1)))

would have generated at least one error you should post the code from the LOG including the error message(s). Best is to copy from the log and then paste into a code box to maintain the text formatting of the messages.

 

 

If I were looking to get separate models for each hour I would sort my data by the hour variable and use BY Hour; instead of having 12 or 24 separate where clauses.

View solution in original post

4 REPLIES 4
ballardw
Super User

if you want two or more conditions in a where clause use AND

  (where=(Month in(6,7,8) and Hour in(1)) )

same with temperature

 

and   55 le temperature le 65

 

And "Didn't work" is awful vague. Since the syntax you show

(where=(Month in(6,7,8))(Hour in(1)))

would have generated at least one error you should post the code from the LOG including the error message(s). Best is to copy from the log and then paste into a code box to maintain the text formatting of the messages.

 

 

If I were looking to get separate models for each hour I would sort my data by the hour variable and use BY Hour; instead of having 12 or 24 separate where clauses.

matt23
Quartz | Level 8

Sorry, one more question:

How can I edit my code to make the x axis go from 60-95 in every plot:

 

proc sort data=matt (where=(Month in(6,7,8)));
by Month Hour;
run;

proc sgplot data=matt (where=(Month in(6,7,8)));
scatter x=Temperature y=Load;
by Hour;
xaxis label="Temperature (degrees F)";
yaxis label="Load (MW)";
title 'Load vs Temperature';
run;
ballardw
Super User

@matt23 wrote:

Sorry, one more question:

How can I edit my code to make the x axis go from 60-95 in every plot:

 

proc sort data=matt (where=(Month in(6,7,8)));
by Month Hour;
run;

proc sgplot data=matt (where=(Month in(6,7,8)));
scatter x=Temperature y=Load;
by Hour;
xaxis label="Temperature (degrees F)";
yaxis label="Load (MW)";
title 'Load vs Temperature';
run;

Add a VALUES option to the Xaxis statement. You could either explicitly list the values of interest Values=(60 70 80 95) or use something like values=(60 to 95 by 5) to have a tick mark and value at 60, 65, 70 etc.

matt23
Quartz | Level 8
You're the best!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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