Hi,
do you know the thought when SAS created vbar and vbarparm statements in proc sgplot?
Was the vbar statement the first version ?
And then a new version was build using vbarparm to gain in flexibility?
I can see some features only available in vbarparm but I don't know if there is anything done with vbar which cannot be done with vbarparm.
Cheers
VBAR is a pretty direct descendant of older Proc Gchart bar charts.
The VBARPARM is intended to work with summarized data and not do the summary in the procedure. So you control the vertical hold, you control the horizontal (enough Outer Limits parody). But because you control the summaries you may have to specify things that the calculations in VBAR would provide, or specify them differently because you have to provide variables in the graphing data set.
Vbar and Vbarparm basically differ in the data sets used and that is where the difference comes in. Need the height of one bar to be different because some records of a specific group with complex rules need to be excluded for whatever reason? Vbar won't likely do that in a nice fashion (a Where statement may work but you might spend much time getting it not to effect other values needed for the plot). Do that in creating the set used by Vbarparm.
Rates with desired numerator/denominators can be tricky as well in Vbar.
You may trade off some data step programming for graph code with Vbarparm (and Hbarparm).
Note: when Gchart was all there was in SAS I summarized the data before other than exploratory graphs because the defaults almost never did what I wanted or I spent a lot of time playing with interactions between options. I find it easier to see a value in a data set or print output that can match to points/ bars/ lines on a graph to double check whether everything was applied as intended.
The key difference between VBAR and VBARPARM is that VBAR can compute various statistics for both your bar and the bar limits, whereas VBARPARM draws the bar and limits using only the data provided. Due to the work it does, the VBAR statement is limited to the types of plot overlays that can be used with it, but VBARPARM can be combined with a lot more overlays to make more creative plots.
Which plot you use depends on your goal. If you have pre-summarized your data, you should always use VBARPARM, as it gives you the most rendering flexibility and you do not require the statistics computations. If your data is not summarized, and your are creating single bar charts, multiple bar overlays, or bar-line charts, then VBAR is a better option. If you need a more creative plot, but still need your data summarized, it might be best to pre-summarize your data using PROC MEANS or PROC SUMMARY and use a VBARPARM.
Hope this helps. Let me know if you have any more questions about it.
Thanks!
Dan
VBAR is a pretty direct descendant of older Proc Gchart bar charts.
The VBARPARM is intended to work with summarized data and not do the summary in the procedure. So you control the vertical hold, you control the horizontal (enough Outer Limits parody). But because you control the summaries you may have to specify things that the calculations in VBAR would provide, or specify them differently because you have to provide variables in the graphing data set.
Vbar and Vbarparm basically differ in the data sets used and that is where the difference comes in. Need the height of one bar to be different because some records of a specific group with complex rules need to be excluded for whatever reason? Vbar won't likely do that in a nice fashion (a Where statement may work but you might spend much time getting it not to effect other values needed for the plot). Do that in creating the set used by Vbarparm.
Rates with desired numerator/denominators can be tricky as well in Vbar.
You may trade off some data step programming for graph code with Vbarparm (and Hbarparm).
Note: when Gchart was all there was in SAS I summarized the data before other than exploratory graphs because the defaults almost never did what I wanted or I spent a lot of time playing with interactions between options. I find it easier to see a value in a data set or print output that can match to points/ bars/ lines on a graph to double check whether everything was applied as intended.
There is one other flavor called VBARBASIC, which follows the GTL BarChart features. It summarizes the data by group and class, but does not have the additional "GCHART" like features. Thus, you can combine it with more plot types.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.