I have 2 columns (t1 and t2) created by catt or coalesceC from multiple columns (v1:v4) similar to the below.
| v1 | v2 | v3 | v4 | t1 | t2 | |
| 1 | 1 | |||||
| 2 | 2 | |||||
| 3 | 3 | |||||
| 4 | --> | 4 | ||||
| 5 | 5 | |||||
| 7 | 7 | |||||
| 5 | 5 | |||||
| 8 | 8 |
I then run the following code.
proc sgplot have;
vbar t1;
vbar t2;
run;Then I get the following error message that I don't understand.
ERROR: The same category variable must be used for summarized plots.
I finally found the solution I was looking for. Replace vbar in the above with vbarbasic as shown below:
proc sgplot data=have;
vbarbasic t1;
vbarbasic t2;
run;
The error tells you pretty much everything. VBAR takes as first parameter a category variable for summarisation. You can only have one. Why have the data in two columns? Why not coalesce the t values an have a category variable:
| v1 | v2 | v3 | v4 | T | cat | |
| 1 | 1 | 1 | ||||
| 2 | 2 | 2 | ||||
| 3 | 3 | 1 |
Then use cat as a group.
There is plenty of examples out there, first google hit:
Also, you may find this blog helpful, it covers everything graph orientated.
I finally found the solution I was looking for. Replace vbar in the above with vbarbasic as shown below:
proc sgplot data=have;
vbarbasic t1;
vbarbasic t2;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.