I want to generate a "step" plot (CDF) and I'm trying to change the line color using the dattrmap option. But color are not changing. Below is my code:
%MACRO ATRRMAP(fich=,var=);
proc freq data=&fich noprint;
tables &var/nocum nopercent norow nocol out=freq&var;
format _all_;
where &var^=.;
run;
data test;
set freq&var end=eof;
call symputx("mvCAT"||strip(_N_),&var);
if eof then call symputx("NB",_N_);
run;
data myattrmap;
length id $20 value 3 linecolor $10 pattern 3 fillcolor $20;
%do i=1 %to &NB;
id='myid';
value = &&mvCAT&i;
linecolor=cats("grey",put(&i*5,hex2.));
%if &i=1 or &i=5 or &i=9 %then %do;
pattern = 1;
%end;%else %if &i=2 or &i=6 or &i=10 %then %do;
pattern = 15;
%end;%else %if &i=3 or &i=7 or &i=11 %then %do;
pattern = 2;
%end;%else %if &i=4 or &i=8 or &i=12 %then %do;
pattern = 8;
%end;%else %do;
pattern = 41;
%end;
fillcolor=cats("grey",put(&i*5,hex2.));
output;
%end;
run;
%MEND ATRRMAP;
The generated data look like the following:
id value pattern fillcolor
myid -6 1 CXbdc3c7
myid -5 2 CXbdc3c7
myid -4 8 CXbdc3c7
Then, I used the sgplot:
PROC SGPLOT DATA=cumul sganno=annotation NOBORDER dattrmap=myattrmap;
STEP X=variable Y=percent/GROUP=newgroup attrid=myid;
YAXIS LABEL="Cumulative percentage of patients" VALUES=(0 TO 100 BY
10);
XAXIS LABEL=" " VALUES=(-4 to 4 by 0.5) ;
KEYLEGEND /TITLE=" " LOCATION=INSIDE POSITION=BOTTOMRIGHT ACROSS=1
DOWN=3 NOBORDER;
RUN;
The data myfile used with sgplot looks like the following:
variable percent newgroup
-3.66 2.70 -6
-3.41 5.40 -6
-3.26 8.11 -6
-3.28 5.8 -5
-2.97 13.51 -5
I would like to have a grey gradient. But first, I would simply like to choose, with dattrmap, color lines on my plot. I try with fillcolor and linecolor but it did not work. I try to change the color directly in the SGPLOT statement with the datacontrastcolors option of styleattrs and it works. Does someone see what am I missing ?