turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- BI
- /
- Enterprise Guide
- /
- Automating a process

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

3 weeks ago

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:

Obs | Hour | _MODEL_ | _TYPE_ | _DEPVAR_ | _RMSE_ | Intercept | Temperature | DewPoint | Load |

1 | 0 | MODEL1 | PARMS | Load | 4121.22 | 72068.94 | -440.384 | 328.518 | -1 |

2 | 1 | MODEL1 | PARMS | Load | 3840.58 | 70860.54 | -491.293 | 341.535 | -1 |

3 | 2 | MODEL1 | PARMS | Load | 3619.64 | 70084.57 | -509.326 | 327.479 | -1 |

4 | 3 | MODEL1 | PARMS | Load | 3455.33 | 70209.15 | -550.968 | 338.977 | -1 |

5 | 4 | MODEL1 | PARMS | Load | 3388.95 | 70123.33 | -545.392 | 315.663 | -1 |

6 | 5 | MODEL1 | PARMS | Load | 3348.44 | 71083.93 | -566.492 | 316.459 | -1 |

7 | 6 | MODEL1 | PARMS | Load | 3326.66 | 73121.29 | -581.957 | 307.265 | -1 |

8 | 7 | MODEL1 | PARMS | Load | 3399.56 | 76572.61 | -670.97 | 371.085 | -1 |

9 | 8 | MODEL1 | PARMS | Load | 3491.99 | 76623.23 | -544.325 | 300.572 | -1 |

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

Hour | WeekendDew | WeekdayDew |

0 | 328.518 | 234 |

1 | 341.535 | 234 |

2 | 327.479 | 342 |

3 | 338.977 | 234 |

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to matt23

3 weeks ago

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to matt23

3 weeks ago

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;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to matt23

3 weeks ago

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to matt23

3 weeks ago

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to matt23

3 weeks ago

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