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;
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.
Look up,the ATTRPRIORITY option9n the ODS GRAPHICS statement or on here.
That I did and tried both variants in both the ODs graphics reset and style template changes to no avail.
Hmm..
Lawrence
Programming errors...
Getting closer-
Lawrence
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.
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!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.