The SAS Output Delivery System and reporting techniques

Getting correct colors in ODS output using attrid mapping

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 161
Accepted Solution

Getting correct colors in ODS output using attrid mapping

[ Edited ]

Hello all- 

So I am trying to output an excel ODS document using SGPLOT and a scatter plot- 

 

Got the code below to work except for the fact that the colors do not render as requested-in that I am specifying two colors-

green and tan- In the windowing environment it does not render correctly at all-it comes out blue and red. However in that environment I am less concerned. 

 

When it actually outputs to excel-I get the green but not the tan- 

I am using the sashelp.cars dataset as an example- 

Any assistance appreciated. Thank you

 

Lawrence

 

proc sql;
    create table cars as select distinct make, sum(MSRP) as MSRP, 10 as line, case 
        when make in ('BMW', 'Dodge', 'Jaguar') then 1 else 0 end as pref from 
        sashelp.cars Where substr(make, 1, 1) in ('A', 'B', 'D', 'J', 'M') group by 
        make;
quit;

proc sql;
    create table attrmap as select distinct make as value, case when pref=1 then 
        '#c9df8a' else 'tan' end as markercolor, 'MYID' as ID from cars;
quit;

ods excel file="C:\temp\car.xlsx" style=Seaside options(sheet_name="Example" 
    SHEET_INTERVAL='PAGE' autofilter='NO' FROZEN_ROWHEADERS='no' 
    embedded_titles='yes' embedded_footnotes='yes' embed_titles_once='on' 
    embedded_titles='on' gridlines='off' START_AT='3,3');
title1 ls=1.5 "xxxx ^*";
ods graphics / reset width=10in height=6in;

proc sgplot data=cars dattrmap=attrmap;
    styleattrs DATACONTRASTCOLORS=(black);
    scatter x=make y=line /group=pref attrid=myid markerattrs=(size=40 
        symbol=circlefilled) filledoutlinedmarkers markeroutlineattrs=(thickness=0) 
        dataskin=pressed datalabel=MSRP SPLITCHAR="\" datalabelpos=center;
    keylegend / location=outside position=right title=' ' sortorder=descending;
    YAXIS LABEL="CAR MSRP SUM";
    XAXIS LABEL=" ";
run;

ods _all_ close;

 


Accepted Solutions
Solution
‎01-22-2018 02:06 PM
Super User
Posts: 24,010

Re: Getting correct colors in ODS output using attrid mapping

I think it should be fillcolor not marker colour and to specify colours usually its CX then the hex code, if that's what you're trying to use. 

proc sql;
    create table attrmap as select distinct make as value, case when pref=1 then 
        'CXc9df8a' else 'tan' end as fillcolor, 'MYID' as ID from cars;
quit;

Not sure if this will help. Note that I formatted the code in the first post.

View solution in original post


All Replies
Super User
Posts: 24,010

Re: Getting correct colors in ODS output using attrid mapping

Look up,the ATTRPRIORITY option9n the ODS GRAPHICS statement or on here. 

 

Regular Contributor
Regular Contributor
Posts: 161

Re: Getting correct colors in ODS output using attrid mapping

That I did and tried both variants   in both the ODs graphics reset and  style template changes to no avail. 

Hmm.. 

 

Lawrence

 

Regular Contributor
Regular Contributor
Posts: 161

Re: Getting correct colors in ODS output using attrid mapping

Programming errors... 

Getting closer- 

 

Lawrence

 

Solution
‎01-22-2018 02:06 PM
Super User
Posts: 24,010

Re: Getting correct colors in ODS output using attrid mapping

I think it should be fillcolor not marker colour and to specify colours usually its CX then the hex code, if that's what you're trying to use. 

proc sql;
    create table attrmap as select distinct make as value, case when pref=1 then 
        'CXc9df8a' else 'tan' end as fillcolor, 'MYID' as ID from cars;
quit;

Not sure if this will help. Note that I formatted the code in the first post.

Regular Contributor
Regular Contributor
Posts: 161

Re: Getting correct colors in ODS output using attrid mapping

The main error I had made was that I had missed declaring the class variable as 'value'. Once I had did that, it seem to work much better! 

Thanks! 

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 286 views
  • 0 likes
  • 2 in conversation