🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-23-2019 09:34 AM
(2609 views)
proc sort data=sashelp.class out=class;
by sex;
run;
proc sgplot data=class;
styleattrs;
by sex;
vbox height/group=age grouporder=ascending;
run;
produces this result:
How can I do this so that the color for 11 year olds is the same on each plot, and the color for 12 year olds is the same on each plot, etc.?
--
Paige Miller
Paige Miller
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just use a discrete attributes map, like the following:
proc sort data=sashelp.class out=class;
by sex;
run;
data attrmap;
retain id "myid" linecolor "black";
length fillcolor $ 6;
input value $ fillcolor $;
cards;
11 orange
12 purple
13 green
14 blue
15 red
16 gold
;
run;
proc sgplot data=class dattrmap=attrmap;
by sex;
vbox height/group=age attrid=myid grouporder=ascending;
run;
Hope this helps!
Dan
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Just use a discrete attributes map, like the following:
proc sort data=sashelp.class out=class;
by sex;
run;
data attrmap;
retain id "myid" linecolor "black";
length fillcolor $ 6;
input value $ fillcolor $;
cards;
11 orange
12 purple
13 green
14 blue
15 red
16 gold
;
run;
proc sgplot data=class dattrmap=attrmap;
by sex;
vbox height/group=age attrid=myid grouporder=ascending;
run;
Hope this helps!
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, @DanH_sas , I have used discrete attribute maps in the past and totally forgot about them. But this works!
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If your group variable within levels of the by variable have the same minimum and the same values except for possibly max then a modification to sort works:
proc sort data=sashelp.class out=class; by sex age; run; proc sgplot data=class; styleattrs; by sex; vbox height/group=age grouporder=ascending; run;
but when there are differing gaps in the values of the group variable the color no longer aligns.