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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

5 REPLIES 5
Reeza
Super User

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

 

LB
Quartz | Level 8 LB
Quartz | Level 8

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

Hmm.. 

 

Lawrence

 

LB
Quartz | Level 8 LB
Quartz | Level 8

Programming errors... 

Getting closer- 

 

Lawrence

 

Reeza
Super User

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.

LB
Quartz | Level 8 LB
Quartz | Level 8

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! 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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