Desktop productivity for business analysts and programmers

Scatter plot for two different groups

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Scatter plot for two different groups

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;

 

MonthDayHourLoadTemperature
1107023220.87
1216842220.61
1326701420.27
1436606820.52
1546578121.45
1656630821.69
1066755921.87
1176915022.39
1286978822.72

Accepted Solutions
Solution
‎06-26-2018 02:37 PM
Super User
Posts: 13,930

Re: Scatter plot for two different groups

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.

 

 

 

 

View solution in original post


All Replies
Solution
‎06-26-2018 02:37 PM
Super User
Posts: 13,930

Re: Scatter plot for two different groups

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.

 

 

 

 

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 85 views
  • 0 likes
  • 2 in conversation