BookmarkSubscribeRSS Feed
ThaoLinh
Calcite | Level 5

Hi all,

 

I'm trying to plot vbar with group option. The current results are as follows:

 

PROC SQL NOPRINT;
	CREATE TABLE TEMP00 AS 
		SELECT MAKE, ORIGIN, COUNT(*) AS NUM, MEAN(INVOICE) AS  INVOICE, MEAN(MPG_CITY) AS MPG_CITY
			FROM SASHELP.CARS
				GROUP BY MAKE, ORIGIN
					HAVING (CALCULATED NUM)>10
						ORDER BY ORIGIN, (CALCULATED INVOICE);
QUIT;

PROC SGPLOT DATA=TEMP00;
	VBAR MAKE/ RESPONSE=INVOICE GROUP=ORIGIN NOOUTLINE  MISSING ;
	VLINE MAKE/ RESPONSE=MPG_CITY GROUP=ORIGIN  Y2AXIS LINEATTRS=(COLOR=CX9CBA5F PATTERN=SOLID THICKNESS=2PX)  
		MARKERATTRS=(SYMBOL=CIRCLEFILLED COLOR=CX9CBA5F) MARKERS MISSING;
	TITLE "Summary data by Make";
	Y2AXIS LABEL="Mean MPG City";
	YAXIS LABEL="Mean Invoice";
	XAXIS LABEL="Make" DISCRETEORDER=DATA;
	LABEL INVOICE="Mean Invoice" MPG_CITY="Mean MPG City";
RUN;

Sgplot.png

The graph divides groups by color. What I want is a graph that divides the groups by distance. Please tell me how to do it.

Sincerely thank you,

1 REPLY 1
yabwon
Onyx | Level 15

if you don't mind disgusting [😅] solution try this:

PROC SQL NOPRINT;
	CREATE TABLE TEMP00 AS 
		SELECT MAKE, ORIGIN, COUNT(*) AS NUM, MEAN(INVOICE) AS  INVOICE, MEAN(MPG_CITY) AS MPG_CITY
			FROM SASHELP.CARS
				GROUP BY MAKE, ORIGIN
					HAVING (CALCULATED NUM)>10
						ORDER BY ORIGIN, (CALCULATED INVOICE);
QUIT;

data TEMP01;
  set TEMP00 end=eof;
  by ORIGIN notsorted;
  output;
  if last.ORIGIN and not EOF;
    INVOICE = .;
    MPG_CITY = .;
    i + 1;
    MAKE = repeat(" ", i) !! "12"x;
    output;
run;

PROC SGPLOT DATA=TEMP01;
	VBAR MAKE/ RESPONSE=INVOICE GROUP=ORIGIN NOOUTLINE  MISSING /*!*/ NOZEROBARS /*!*/  ;
	VLINE MAKE/ RESPONSE=MPG_CITY GROUP=ORIGIN  Y2AXIS LINEATTRS=(COLOR=CX9CBA5F PATTERN=SOLID THICKNESS=2PX)  
		MARKERATTRS=(SYMBOL=CIRCLEFILLED COLOR=CX9CBA5F) MARKERS MISSING;
	TITLE "Summary data by Make";
	Y2AXIS LABEL="Mean MPG City";
	YAXIS LABEL="Mean Invoice";
	XAXIS LABEL="Make" DISCRETEORDER=DATA;
	LABEL INVOICE="Mean Invoice" MPG_CITY="Mean MPG City";
RUN;

result:

yabwon_0-1680258394501.png

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 377 views
  • 0 likes
  • 2 in conversation