I want one scatter plot with two different groups on it. Each different color. I want weekday and weekend groups.
Weekend when day=0,6, and weekday when day=1,2,3,4,5
Here's what I have so far but I don't know how to divide the days into two groups
proc sgplot data=matt; scatter x=DewPoint y=Load / group by ??????; xaxis label="Temp"; yaxis label="Load"; run;
| Month | Day | Hour | Load | Temperature |
| 1 | 1 | 0 | 70232 | 20.87 |
| 1 | 2 | 1 | 68422 | 20.61 |
| 1 | 3 | 2 | 67014 | 20.27 |
| 1 | 4 | 3 | 66068 | 20.52 |
| 1 | 5 | 4 | 65781 | 21.45 |
| 1 | 6 | 5 | 66308 | 21.69 |
| 1 | 0 | 6 | 67559 | 21.87 |
| 1 | 1 | 7 | 69150 | 22.39 |
| 1 | 2 | 8 | 69788 | 22.72 |
One way, create a new variable :
data want;
set matt;
if day in (1:5) then groupvar='Weekday';
else groupvar='Weekend';
run;
use this data set and the variable groupvar with the group= option.
OR create a custom format for the day variable
Proc format;
value myweekday
0,6 = 'Weekend'
1 - 5 = 'Weekday'
;
run;
and use group=day and add a separate statement to use the format:
Format day myweekday.;
to the sgplot code.
One way, create a new variable :
data want;
set matt;
if day in (1:5) then groupvar='Weekday';
else groupvar='Weekend';
run;
use this data set and the variable groupvar with the group= option.
OR create a custom format for the day variable
Proc format;
value myweekday
0,6 = 'Weekend'
1 - 5 = 'Weekday'
;
run;
and use group=day and add a separate statement to use the format:
Format day myweekday.;
to the sgplot code.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.