BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
swannie
Obsidian | Level 7

Hi,

 

I'm setting up the code to produce a powerpoint slide of a swim lane plot in SAS 9.4, and it's perfect except that the lanes are not the correct color. The sgplot code for it is below.  I've been trolling online for any hint about how to change the color (which I think may be from the PowerPointLight template) to what I want it to be.  My latest shot at it is to change the template thusly:

 

proc template;

define style styles.swimplot;

parent= styles.powerpointlight;

class GraphDataDefault /

endcolor = GraphColors('gramp3cend')

neutralcolor = GraphColors('gramp3cneutral')

startcolor = GraphColors('gramp3cstart')

markersize = 7px

markersymbol = "circle"

linethickness = 1px

linestyle = 1

contrastcolor = GraphColors('gcdata')

color = cxFAE85C;

 

*style GraphColors / 'gdata' = cxFAE85C; *#FAE85C;

end;

run;

 

This does not work.  I want the lanes to be #FAE85C, a dark red, and they are blue blue blue.  Any help vastly appreciated.


Swannie

 

ods graphics / reset=all border=off HEIGHT = 170mm WIDTH=250mm;

ods powerpoint file = "S:\Swim_Lane_Plot_&today..PPTX" style=styles.swimplot;

 

proc sgplot data=data.tos sganno=data.anno noautolegend;

format dosen fdosen.;

hbarparm category=subjn response=tos/group=dosen name="chrt" barwidth=1.0 dataskin=sheen;

scatter X=ttrc Y=subjn /markerattrs=(symbol=circlefilled size=12 color=black);

scatter X=ttrc Y=subjn /markerattrs=(symbol=circlefilled size=10 color=white);

yaxis type=discrete display=(novalues noticks) labelattrs=(size=18 weight=bold) label="Treated Subjects";

xaxis type=linear labelattrs=(size=14 weight=bold) VALUEATTRS= (Weight=Bold) label="Weeks" values=(0 to 78 by 6);

run;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
swannie
Obsidian | Level 7

First post errors.  The issue is not the data; it's the template (or something) that's controlling the colors for the slide.  The group dose (which only has 1 value in this graphic) is the variable that's getting the color assigned; lanes are created for each subjn of length tos.  I'm attaching the slide with the incorrect colors,and have pasted in the proc template that produced the correct color for the pdf file but not for the pptx file.  I have attached a zip file with the correct and incorrect colors in pdf and pptx files, respectively.  And the color I want is #840028, not #FAE85C.

 

proc template;

define style styles.arial;

class graphwalls /

frameborder=off;

style GraphData1 /

ContrastColor=#840028

Color=#840028

MarkerSymbol="SquareFilled"

Linestyle=1;

end;

run;

View solution in original post

8 REPLIES 8
ballardw
Super User

You say "the lanes are not the correct color" but it isn't obvious 1) what color anything should be as 2) there is no data and 3) no example output. So we have no idea what colors are displayed for what variable. We cannot even tell which variable is a "lane".

 

You should provide some example data in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

 

 

 

swannie
Obsidian | Level 7

First post errors.  The issue is not the data; it's the template (or something) that's controlling the colors for the slide.  The group dose (which only has 1 value in this graphic) is the variable that's getting the color assigned; lanes are created for each subjn of length tos.  I'm attaching the slide with the incorrect colors,and have pasted in the proc template that produced the correct color for the pdf file but not for the pptx file.  I have attached a zip file with the correct and incorrect colors in pdf and pptx files, respectively.  And the color I want is #840028, not #FAE85C.

 

proc template;

define style styles.arial;

class graphwalls /

frameborder=off;

style GraphData1 /

ContrastColor=#840028

Color=#840028

MarkerSymbol="SquareFilled"

Linestyle=1;

end;

run;

Jay54
Meteorite | Level 14

Not sure what your goal is, but it seems you want to change the colors of the hbars.  However, you are using a group variable, so the colors will come from the GraphData1-12 elements.  If you are using SAS 9.4, you need not change the style, just set the colors you want for each group in the STYLEATTRS statement.

 

There are many examples in Graphically Speaking blog.  Here is one recent one:  http://blogs.sas.com/content/graphicallyspeaking/2017/07/30/clinical-graphs-waterfall-plot/

 

swannie
Obsidian | Level 7

Thank you for your reply and the links, but there is nothing there that leads me to believe that the ods powerpoint template won't override the styleattrs code in proc sgplot.  If it can, what's the purpose of the template?

Jay54
Meteorite | Level 14

You will know only if you try it.  Smiley Happy  The template provides the default settings for colors etc.  These can be overridden by custom settings in the syntax.  Many users prefer to do this in the syntax instead of deriving a new Style.

Jay54
Meteorite | Level 14
ods powerpoint file='Test.pptx';
proc sgplot data=sashelp.class;
  styleattrs datacolors=(cyan pink);
  hbar name / group=sex ;
run;
ods powerpoint close;

 See output with different colors in attached zip file.

swannie
Obsidian | Level 7

Worked like a charm--thanks!  I'm ditching the proc template and going with this in the future.

 

swannie

ballardw
Super User

@swannie wrote:

Thank you for your reply and the links, but there is nothing there that leads me to believe that the ods powerpoint template won't override the styleattrs code in proc sgplot.  If it can, what's the purpose of the template?


Post data and  plot code where the settings in the plot code do not work.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1771 views
  • 1 like
  • 3 in conversation