BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
capam
Pyrite | Level 9

I have 2 columns (t1 and t2)  created by catt or coalesceC from multiple columns (v1:v4) similar to the below.

 

v1v2v3v4 t1t2
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.

1 ACCEPTED SOLUTION

Accepted Solutions
capam
Pyrite | Level 9

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;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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      
    3   1  

Then use cat as a group.

capam
Pyrite | Level 9
Can you give an example?
RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is plenty of examples out there, first google hit:

https://blogs.sas.com/content/sascom/2011/08/22/how-to-make-a-cluster-grouped-bar-chart-graph-using-...

 

Also, you may find this blog helpful, it covers everything graph orientated.

http://blogs.sas.com/content/graphicallyspeaking/

capam
Pyrite | Level 9

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1172 views
  • 0 likes
  • 2 in conversation