BookmarkSubscribeRSS Feed
Melk
Lapis Lazuli | Level 10

I have a vertical bar chart overlaid with a series plot of individual IDs paneled by treatment group. I would like the symbols for the marker attributes to be different by the panelby variable rather than the ID variable for the series, and the color of the lines as well. How can I specify this in my code?

 

 

8 REPLIES 8
Jay54
Meteorite | Level 14

Just set the GROUP= role to the classification variable you want.  This can be the same as the PANELBY variable if you want.

Melk
Lapis Lazuli | Level 10

Thank you, this worked for the vertical bar plots but when I use it, my error bars disappear. Not sure why?

 

for the series plot, since I am grouping by individual patient number here, I would like the marker attributes to be different by the panel variable. Perhaps one to be a circlefilled and the other to be trianglefilled. Any way I can do that?

 

Here is my code:

 


proc sgpanel data=dat noautolegend;
    panelby group;
    vbarparm category=visit response=mean /group=group
        limitlower=low limitupper=up;
    series x=visit y=yvar/group=id
         markers markerattrs=(size=12 symbol=circlefilled)  lineattrs=(pattern=solid color=black);
run;

 

 

Jay54
Meteorite | Level 14

For Series plot the GROUP is used to join the points to form the line.  However, you can use the GROUPLC to get line color by another classifier.  Use GROUPMS to set symbols by another classifier.  Note, the GROUP must be the lowest level of classification.  Do not set marker symbol in the MARKERATTRS option.  Use STYLEATTRS to set the new list of markers you want.

 

Since your bars are now grouped by "group" variable, make sure your upper and lower error values are also correctly grouped.

Melk
Lapis Lazuli | Level 10

Great thanks Sanjay!

 

Also, how can I customize a keylegend based on my grouplc groupmc and groupms variables? the auto legend is outputting by ID, whereas I need this by my paneled group variable.

Jay54
Meteorite | Level 14

With SGPANEL, you can have one key legend outside.  You can control which plots are included by providing NAME= for each plot, then include only the required names in the KEYLEGEND statement.  See examples here:  https://blogs.sas.com/content/graphicallyspeaking/2017/10/27/legend-items/

 

 

 

Melk
Lapis Lazuli | Level 10

I am not sure why but my error bars are not showing up with the group statement- have tried everything i can think of.

Jay54
Meteorite | Level 14

Hard to say without program.  Attache your FULL program with SAMPLE data.  The, it is easier to debug the issue.

ballardw
Super User

@Melk wrote:

I am not sure why but my error bars are not showing up with the group statement- have tried everything i can think of.


From the documentation for VBARPARM if you do not specify a Grouporder the default is STACK for the group variable. Limits do not appear when Grouporder=stack. You might try Grouporder=cluster.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 3988 views
  • 3 likes
  • 3 in conversation