Data visualization with SAS programming

control of graphics color in ods powerpoint

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

control of graphics color in ods powerpoint

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;


Accepted Solutions
Solution
2 weeks ago
Occasional Contributor
Posts: 8

Re: control of graphics color in ods powerpoint

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

Attachment

All Replies
Super User
Posts: 10,483

Re: control of graphics color in ods powerpoint

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.

 

 

 

 

Solution
2 weeks ago
Occasional Contributor
Posts: 8

Re: control of graphics color in ods powerpoint

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;

Attachment
SAS Super FREQ
Posts: 1,104

Re: control of graphics color in ods powerpoint

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/

 

Occasional Contributor
Posts: 8

Re: control of graphics color in ods powerpoint

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?

SAS Super FREQ
Posts: 1,104

Re: control of graphics color in ods powerpoint

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.

SAS Super FREQ
Posts: 1,104

Re: control of graphics color in ods powerpoint

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.

Attachment
Occasional Contributor
Posts: 8

Re: control of graphics color in ods powerpoint

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

 

swannie

Super User
Posts: 10,483

Re: control of graphics color in ods powerpoint


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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 174 views
  • 1 like
  • 3 in conversation