Data visualization with SAS programming

Band from 100 to 150

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

Band from 100 to 150

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


Accepted Solutions
Solution
‎01-03-2017 02:47 PM
SAS Super FREQ
Posts: 3,630

Re: Band from 100 to 150

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."

View solution in original post


All Replies
Super User
Posts: 11,134

Re: Band from 100 to 150

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.

Contributor
Posts: 41

Re: Band from 100 to 150

I need a band extending from 100 to 150 not two reference lines. 

 

Solution
‎01-03-2017 02:47 PM
SAS Super FREQ
Posts: 3,630

Re: Band from 100 to 150

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."

Respected Advisor
Posts: 4,817

Re: Band from 100 to 150

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;
PG
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 170 views
  • 0 likes
  • 4 in conversation