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?
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.
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.
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;
@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.
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!
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.
Ready to level-up your skills? Choose your own adventure.