- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-31-2023 05:51 AM
(580 views)
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;
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
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
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