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

Hello,

 

With this syntax:

proc sgplot data=plot ;
   vbox value /  category=DV group=genre ;
run;

SGPLOT produces a VBOX with different colors for the two groups defined in GROUP=

 

See graphs below. 

 

Instead, I would like the two levels of groups (liteary and popular) to have different patterns (for instance, small dots for one and small x for the other). 

I have been looking into various options with ATTRMAP, but I do not seem to be able to get it.

 

Suggestions?

 

Screenshot 2024-06-17 at 16.32.29.png 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

I think you are saying that you want the symbols for the markers to be different for the different groups? If so, consider using ATTRPRIORITY=NONE

ods graphics / attrpriority=none;

proc sgplot data=sashelp.cars(where=(origin^="USA"));
     vbox mpg_city /group=origin;
run;

For more on this topic, see "The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS graphics," which describes all the ways that you can get the group attributes to vary.

View solution in original post

5 REPLIES 5
ballardw
Super User

Fill patterns are sort of out of style. SAS supports some line styles, left right and cross with different weight lines.

 

proc sgplot data=sashelp.class;
     styleattrs datafillpatterns=( L1 X2);
     vbox height /group=sex   fillpattern nofill;
     ;
run;

The styleattrs sets the first fill to a left slanting light weight line and the second to across slightly heavier lines.

Fill pattern in the plot says to use them and the NOFILL removes the background color.

emaneman
Pyrite | Level 9

Hello,

thanks, but it does not seem to be working. See the adapted syntax and result below.

 

proc sgplot data=plot  ;
     styleattrs datafillpatterns=( L1 X2);
   vbox value /  category=DV group=genre fillpattern nofill;
run;

Produces this result:

 

Screenshot 2024-06-17 at 17.01.47.png

Rick_SAS
SAS Super FREQ

I think you are saying that you want the symbols for the markers to be different for the different groups? If so, consider using ATTRPRIORITY=NONE

ods graphics / attrpriority=none;

proc sgplot data=sashelp.cars(where=(origin^="USA"));
     vbox mpg_city /group=origin;
run;

For more on this topic, see "The interaction between ATTRPRIORITY, CYCLEATTRS, and STYLEATTRS in ODS graphics," which describes all the ways that you can get the group attributes to vary.

emaneman
Pyrite | Level 9

hello Rick,

yes, that worked!

Thank you.

E

yabwon
Onyx | Level 15

How about Discrete Attribute Map Data Sets ?

data plot;
  do DV='Legal BERT', 'BERT';
    do genre = "literary", "popular";
      k+1;
      do i = 1 to 64+k;
        value = rannor(42)+k;
        output;
      end; 
    end;
  end;
run;

data DiscreteAttributeMapDS;
length linecolor $ 9 fillcolor $ 9 markersymbol markercolor $ 20;
input ID $ value $ linecolor $ fillcolor $ markersymbol $ markercolor $;
datalines;
MYID  literary red pink CircleFilled gold
MYID  popular blue lightblue Star green
;
run;

proc sgplot data=plot DATTRMAP=DiscreteAttributeMapDS;
   vbox value /  category=DV group=genre ATTRID=MYID;
run;

yabwon_0-1718638255710.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



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 197 views
  • 0 likes
  • 4 in conversation