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

Sorry for bad explanation but here's what I have:

 

I want a dataset with SLOPES for every hour. Now, I run this code:

proc reg data=have outest=outdata NOPRINT;
where Month in (3,4,5);
where also Weekday in (1,2,3,4,5);
model Load=Temperature DewPoint;
by Hour;
run;

proc reg data=have outest=outdata NOPRINT;
where Month in (3,4,5);
where also Weekday in (0,6);
model Load=Temperature DewPoint;
by Hour;
run;

and I get two tables that look similar to this:

 

ObsHour_MODEL__TYPE__DEPVAR__RMSE_InterceptTemperatureDewPointLoad
10MODEL1PARMSLoad4121.2272068.94-440.384328.518-1
21MODEL1PARMSLoad3840.5870860.54-491.293341.535-1
32MODEL1PARMSLoad3619.6470084.57-509.326327.479-1
43MODEL1PARMSLoad3455.3370209.15-550.968338.977-1
54MODEL1PARMSLoad3388.9570123.33-545.392315.663-1
65MODEL1PARMSLoad3348.4471083.93-566.492316.459-1
76MODEL1PARMSLoad3326.6673121.29-581.957307.265-1
87MODEL1PARMSLoad3399.5676572.61-670.97371.085-1
98MODEL1PARMSLoad3491.9976623.23-544.325300.572-1

Now, I copy these two tables (weekend and weekdays) and play with them in EXCEL to make something like this:

 

HourWeekendDewWeekdayDew
0328.518234
1341.535234
2327.479342
3338.977234

 

Is there a way to automate this somehow so I don't have to make my own table in EXCEL ?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Send the output to different set and merge them while renaming the variable of interest:

proc reg data=have outest=outdata1 NOPRINT;
where Month in (3,4,5);
where also Weekday in (1,2,3,4,5);
model Load=Temperature DewPoint;
by Hour;
run;

proc reg data=have outest=outdata2 NOPRINT;
where Month in (3,4,5);
where also Weekday in (0,6);
model Load=Temperature DewPoint;
by Hour;
run;

data want;
   merge outdata1 (rename=(dewpoint=weekdaydew))
         outdata2 (rename=(dewpoint=weekenddew))
   ;
   by hour;
   keep hour weekenddew weekdaydew;
run;

I think should work. but without input data it is hard to verify.

 

View solution in original post

4 REPLIES 4
TomKari
Onyx | Level 15

Easy peasy!

 

Create your first dataset as OutWeekDay, and your second as OutWeekEnd.

 

Then run

 

proc sql noprint;
	create table Combined as
		select E.Hour, E.Dewpoint as WeekendDew, D.Dewpoint as WeekdayDew
			from OutWeekEnd E join OutWeekDay D on
				E.Hour = D.Hour;
quit;
PGStats
Opal | Level 21

Sure:

 

proc reg data=have outest=outdataDay NOPRINT;
where Month in (3,4,5);
where also Weekday in (1,2,3,4,5);
model Load=Temperature DewPoint;
by Hour;
run;

proc reg data=have outest=outdataEnd NOPRINT;
where Month in (3,4,5);
where also Weekday in (0,6);
model Load=Temperature DewPoint;
by Hour;
run;

data outDataDew;
merge
    outdataDay(rename DewPoint=weekDayDew) 
    outdataEnd(rename DewPoint=weekEndDew);
by hour;
keep hour weekDayDew weekEndDew;
run;
PG
ballardw
Super User

Send the output to different set and merge them while renaming the variable of interest:

proc reg data=have outest=outdata1 NOPRINT;
where Month in (3,4,5);
where also Weekday in (1,2,3,4,5);
model Load=Temperature DewPoint;
by Hour;
run;

proc reg data=have outest=outdata2 NOPRINT;
where Month in (3,4,5);
where also Weekday in (0,6);
model Load=Temperature DewPoint;
by Hour;
run;

data want;
   merge outdata1 (rename=(dewpoint=weekdaydew))
         outdata2 (rename=(dewpoint=weekenddew))
   ;
   by hour;
   keep hour weekenddew weekdaydew;
run;

I think should work. but without input data it is hard to verify.

 

PGStats
Opal | Level 21

If you don't mind a different data structure:

 

data haveReg;
set have;
if month in (3,4,5);
if weekday in (0,6) 
    then dayEnd = "WeekEnd"; 
    else dayEnd = "WeekDay";
run;

proc sort data=haveReg; by dayEnd hour; run;

proc reg data=have outest=outdata NOPRINT;
by dayEnd hour;
model Load=Temperature DewPoint;
run;
PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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