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!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 718 views
  • 2 likes
  • 2 in conversation