Some SGPLOT problems

Accepted Solution Solved
Reply
Contributor
Posts: 60
Accepted Solution

Some SGPLOT problems

I have to kind of problems. First of all I still am unable to control the bar outline colors in sgplot (I can do it with DATTRMAP statement but it is not possible to use it in this case). I have tried to find the correct style attribute in the rtf template but still unable to find it so if someone could kindly provide me the correct attribute to modify.

Here is a picture of my problem (I would need the outlines to be black):

rtf_outlines.JPG

Also there is a drastic difference with my rtf and html output. Here are the identical graphs output in different location:

html_counts.JPG

And it would be really critical for me to get the count datalabels to be shown on the RTF also. How I can force this?


Accepted Solutions
Solution
‎09-26-2014 11:08 AM
SAS Super FREQ
Posts: 709

Re: Some SGPLOT problems

First Question

The outline is controlled by the "contrast" color, see code example below that shows two techniques using a style and using the new STYLEATTRS statement.

The gdata1 and gcdata1 define the color and contrast color

This works with SAS9.4M2

There might be better ways of doing this.

ods path
  (prepend) work.template (update)
;

proc template;
 
define style styles.mystyle;
    parent=styles.listing;
    style GraphColors from GraphColors /
     
'gdata1'=yellow
     
'gcdata1'=black
     
'gdata2'=green
     
'gcdata2'=green
     
'gdata3'=blue
     
'gcdata3'=blue
    ;
  end;
run;

ods graphicsreset=index;
ods html path="c:\temp" file="sample.html"  style=styles.mystyle;
ods rtf path="c:\temp" file="sample.rtf"  style=styles.mystyle;

proc sgplot data=sashelp.cars ;
  hbar type / group=type datalabel;
run;

proc sgplot data=sashelp.cars  ;
  styleattrs
   
datacolors=(yellow red green)
   
datacontrastcolors=(black red green)
  ;
  hbar type / group=type datalabel;
run;

ods html close;
ods rtf close;

View solution in original post


All Replies
Super User
Super User
Posts: 7,988

Re: Some SGPLOT problems

Hi,

Have a look through this blog: http://blogs.sas.com/content/graphicallyspeaking/

Its an excellent resource for anything graph.

As for your second point, what does the code look like?  Gotta say I have never used HTML as an output destination, but haven't seen any major differences betwee, PDF/RTF etc.

Solution
‎09-26-2014 11:08 AM
SAS Super FREQ
Posts: 709

Re: Some SGPLOT problems

First Question

The outline is controlled by the "contrast" color, see code example below that shows two techniques using a style and using the new STYLEATTRS statement.

The gdata1 and gcdata1 define the color and contrast color

This works with SAS9.4M2

There might be better ways of doing this.

ods path
  (prepend) work.template (update)
;

proc template;
 
define style styles.mystyle;
    parent=styles.listing;
    style GraphColors from GraphColors /
     
'gdata1'=yellow
     
'gcdata1'=black
     
'gdata2'=green
     
'gcdata2'=green
     
'gdata3'=blue
     
'gcdata3'=blue
    ;
  end;
run;

ods graphicsreset=index;
ods html path="c:\temp" file="sample.html"  style=styles.mystyle;
ods rtf path="c:\temp" file="sample.rtf"  style=styles.mystyle;

proc sgplot data=sashelp.cars ;
  hbar type / group=type datalabel;
run;

proc sgplot data=sashelp.cars  ;
  styleattrs
   
datacolors=(yellow red green)
   
datacontrastcolors=(black red green)
  ;
  hbar type / group=type datalabel;
run;

ods html close;
ods rtf close;
Contributor
Posts: 60

Re: Some SGPLOT problems

Posted in reply to Bruno_SAS

Bruno Mullers answer solves the first problem. Thanks. However the problem where the datalabels are missing on the RTF is more severe, and urgently would need to get it fixed. Any help is much appreciated.

Contributor
Posts: 60

Re: Some SGPLOT problems

Found the solution myself. For some reason Google will always show me 9.3 documentation results only. Now I found the 9.4 documentation which is much broader. The correct option is DATALABELFITPOLICY=NONE

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 492 views
  • 3 likes
  • 3 in conversation