Hello,
I am creating a plot and there a request to show a band from 100 to 150 to show reference values.
The y-axis has values ranging from 0 to 250 and x-axis is weeks. What is the best way to show a band
using proc template ? I am using SAS 9.4M2
The GTL supports the BANDPLOT statement. Thus you could write:
proc template;
define statgraph bandplot;
begingraph;
layout overlay;
bandplot x=height limitlower=100 limitupper=150 /
name="band"
legendlabel="Overweight";
scatterplot x=height y=weight / primary=true;
discretelegend "band";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=bandplot;
run;
However, you might consider using a BLOCKPLOT statement instead. See the example in the article "Overlay categories on a histogram."
It helps to show what you are starting from.
Likely you will be looking at a REFERENCELINE statement or two. It may be as simple as
Referenceline y=100;
Referenceline y=150;
but where the statments go may depend on what else you are attempting.
I need a band extending from 100 to 150 not two reference lines.
The GTL supports the BANDPLOT statement. Thus you could write:
proc template;
define statgraph bandplot;
begingraph;
layout overlay;
bandplot x=height limitlower=100 limitupper=150 /
name="band"
legendlabel="Overweight";
scatterplot x=height y=weight / primary=true;
discretelegend "band";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=bandplot;
run;
However, you might consider using a BLOCKPLOT statement instead. See the example in the article "Overlay categories on a histogram."
Here is an example based on a SASHELP dataset which you may adapt:
proc sgplot data=sashelp.citiwk;
band x=date lower=9.5 upper=10.5 / fill;
series x=date y=wspca;
xaxis type=time valuesformat=yyweeku6.;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.