Using the procedure listed here, I am looking to add different visual information, either using color or a label for the time variable in the EWMA chart output. Any help is welcome.
data Sample;
input Sample Diameter Time $;
datalines;
1 24.05 Morning
2 23.99 Morning
3 23.95 Morning
4 23.93 Morning
5 23.97 Morning
6 24.02 Morning
7 24.06 Morning
8 24.10 Morning
9 23.98 Morning
10 24.03 Afternoon
11 23.91 Afternoon
12 24.06 Afternoon
13 24.06 Afternoon
14 23.96 Afternoon
15 23.98 Afternoon
16 24.06 Afternoon
17 24.01 Afternoon
18 24.00 Afternoon
19 23.93 Afternoon
20 23.92 Afternoon
21 24.09 Morning
22 24.11 Morning
23 24.05 Morning
24 23.98 Morning
25 23.98 Morning
26 24.06 Morning
27 24.02 Morning
28 24.06 Morning
29 23.97 Morning
30 23.96 Morning
;
proc MACONTROL data=work.Sample ;
ewmachart Diameter * Sample /
weight = 0.4
sigmas = 3.0
outlimits = c;
label Diameter = "Diameter";
label Sample = "Sample";
run;
SGPLOT?
data Sample;
input Sample Diameter Time $;
datalines;
1 24.05 Morning
2 23.99 Morning
3 23.95 Morning
4 23.93 Morning
5 23.97 Morning
6 24.02 Morning
7 24.06 Morning
8 24.10 Morning
9 23.98 Morning
10 24.03 Afternoon
11 23.91 Afternoon
12 24.06 Afternoon
13 24.06 Afternoon
14 23.96 Afternoon
15 23.98 Afternoon
16 24.06 Afternoon
17 24.01 Afternoon
18 24.00 Afternoon
19 23.93 Afternoon
20 23.92 Afternoon
21 24.09 Morning
22 24.11 Morning
23 24.05 Morning
24 23.98 Morning
25 23.98 Morning
26 24.06 Morning
27 24.02 Morning
28 24.06 Morning
29 23.97 Morning
30 23.96 Morning
;
proc MACONTROL data=work.Sample ;
ewmachart Diameter * Sample /
weight = 0.4
sigmas = 3.0
outlimits = c
OUTTABLE=OT
;
label Diameter = "Diameter";
label Sample = "Sample";
run;
data forPlot;
set OT end=_E_;
l=0;
if 10<=Sample<=22 then u=25;
else u=0;
output;
run;
proc sgplot data=forPlot noautolegend;
band x=sample lower=_LCLE_ upper=_UCLE_ / transparency=0 modelname="myname";
band x=sample lower=l upper=u / fillattrs=(color=gold transparency=.2);
step x=sample y=_LCLE_ / name="myname" lineattrs=(color=grey thickness=2);
step x=sample y=_UCLE_ / lineattrs=(color=grey thickness=2);
series x=sample y=_MEAN_ / lineattrs=(color=black thickness=2);
series x=sample y=_EWMA_ / lineattrs=(color=blue thickness=3);
yaxis min=23.90 max=24.10;
run;
result:
Bart
You need to provide an ANNOTATE dataset.
Can you do that?
Use this blog as an example :
How to show recessions (or other ranges) on a time series plot?
By Robert Allison on SAS Learning Post August 22, 2014
https://blogs.sas.com/content/sastraining/2014/08/22/how-to-show-recessions-or-other-ranges-on-a-tim...
Koen
If you want to see all ANNOTATE posts in the SAS blogs , go here :
https://blogs.sas.com/content/tag/annotate/
Koen
Is there a fully reproducible code for the chart mentioned in the post?
SGPLOT?
data Sample;
input Sample Diameter Time $;
datalines;
1 24.05 Morning
2 23.99 Morning
3 23.95 Morning
4 23.93 Morning
5 23.97 Morning
6 24.02 Morning
7 24.06 Morning
8 24.10 Morning
9 23.98 Morning
10 24.03 Afternoon
11 23.91 Afternoon
12 24.06 Afternoon
13 24.06 Afternoon
14 23.96 Afternoon
15 23.98 Afternoon
16 24.06 Afternoon
17 24.01 Afternoon
18 24.00 Afternoon
19 23.93 Afternoon
20 23.92 Afternoon
21 24.09 Morning
22 24.11 Morning
23 24.05 Morning
24 23.98 Morning
25 23.98 Morning
26 24.06 Morning
27 24.02 Morning
28 24.06 Morning
29 23.97 Morning
30 23.96 Morning
;
proc MACONTROL data=work.Sample ;
ewmachart Diameter * Sample /
weight = 0.4
sigmas = 3.0
outlimits = c
OUTTABLE=OT
;
label Diameter = "Diameter";
label Sample = "Sample";
run;
data forPlot;
set OT end=_E_;
l=0;
if 10<=Sample<=22 then u=25;
else u=0;
output;
run;
proc sgplot data=forPlot noautolegend;
band x=sample lower=_LCLE_ upper=_UCLE_ / transparency=0 modelname="myname";
band x=sample lower=l upper=u / fillattrs=(color=gold transparency=.2);
step x=sample y=_LCLE_ / name="myname" lineattrs=(color=grey thickness=2);
step x=sample y=_UCLE_ / lineattrs=(color=grey thickness=2);
series x=sample y=_MEAN_ / lineattrs=(color=black thickness=2);
series x=sample y=_EWMA_ / lineattrs=(color=blue thickness=3);
yaxis min=23.90 max=24.10;
run;
result:
Bart
Thanks, @yabwon
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.