Desktop productivity for business analysts and programmers

Automating a process

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Automating a process

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 ?


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 13,950

Re: Automating a process

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


All Replies
PROC Star
Posts: 1,334

Re: Automating a process

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;
Esteemed Advisor
Posts: 5,627

Re: Automating a process

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
Solution
3 weeks ago
Super User
Posts: 13,950

Re: Automating a process

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.

 

Esteemed Advisor
Posts: 5,627

Re: Automating a process

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
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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