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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.