BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Giovani
Obsidian | Level 7

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;

 

Giovani_2-1710900182030.png

 

 



1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

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:

yabwon_0-1711029975658.png

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

5 REPLIES 5
sbxkoenk
SAS Super FREQ

You need to provide an ANNOTATE dataset.
Can you do that?

  • ANNOTATE=SAS-data-set
    ANNO=SAS-data-set
    specifies an input data set that contains appropriate annotate variables, as described in SAS/GRAPH: Reference. The ANNOTATE= option enables you to add features to the moving average chart (for example, labels that explain out-of-control points). The ANNOTATE= data set is used only when the chart is created as traditional graphics; it is ignored if ODS Graphics is enabled or if you specify the LINEPRINTER option.
    The data set specified with the ANNOTATE= option in the PROC MACONTROL statement is a "global" annotate data set in the sense that the information in this data set is displayed on every chart produced in the current run of the MACONTROL procedure.
  • ANNOTATE2=SAS-data-set
    ANNO2=SAS-data-set
    specifies an input data set that contains appropriate annotate variables that add features to the trend chart (secondary chart) produced with the TRENDVAR= option in the EWMACHART or MACHART statement. This option is ignored if ODS Graphics is enabled or if you specify the LINEPRINTER option.

 

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

sbxkoenk
SAS Super FREQ

If you want to see all ANNOTATE posts in the SAS blogs , go here :

https://blogs.sas.com/content/tag/annotate/

 

Koen

Giovani
Obsidian | Level 7

Is there a fully reproducible code for the chart mentioned in the post?

yabwon
Onyx | Level 15

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:

yabwon_0-1711029975658.png

 

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 5 replies
  • 367 views
  • 1 like
  • 3 in conversation