Let’s create a bar chart in SAS. There are two ways you can go about it: Code or work with the menus provided. We will start with the menus.
Start by clicking on Task and Utilities
Select Graph > Bar Chart
In the new window pane that opens, we need to add Data. Select the browse button
Expand SASHELP (a collection of data sets that came with SAS)
We are going to pick SHOES
Now the red * indicates required fields. The only one bar charts require is Category variable. Hit the plus sign.
Select Product – notice how the code automatically fills in for you now.
Hit the little running man and your chart will appear in the Results
Let’s change the color. – go to Options>Bar Details>Apply bar Color and pick a new color
And now it is red (or whatever color you chose)
Go back to the Data tab and add Region to Group Variable
Notice we now have two dimensions Product and Region. Also notice a legend is auto generated.
Now let’s try doing via code, use the following code:
proc sgplot data=SASHELP.SHOES; vbar Product / group=Region groupdisplay=Stack name='Bar'; yaxis grid; run;
Note I changed groupdisplay to Stack. Here are the results