I need generate 3-by-2 plots, which the code below does. BUT also need let the lines are with varied colors.
There are GROUPLC= and styleattrs datacontrastcolors=(red green black orange blue cyan); BUT only for multiple lines within a single plot.
How to get 3-by-2 plots with controlled/varied colors?
Any other PROC is fine.
Thanks,
data _test;
do grp=1 to 6;
do ind=1 to 100;
yvalue=sin(ind/10)+grp;
gx=grp;
output;
end;
end;
run;quit;
ods layout gridded columns=3 rows=2 advance=bygroup;
proc sgplot data=_test noautolegend uniform=xscale;
by grp;
series x=ind y=yvalue / group=grp lineattrs=( thickness=2 pattern=solid) grouplc=grp ;
refline 30/axis=x lineattrs=(color=red thickness=2 pattern=solid);
run;
ods layout end;
I think this could be done by using a discrete attribute map, to map each group value to a color.
data _test;
do grp=1 to 6;
do ind=1 to 100;
yvalue=sin(ind/10)+grp;
gx=grp;
output;
end;
end;
run;quit;
data mymap ;
input value linecolor $10. ;
retain id "grp" ;
cards ;
1 Red
2 Blue
3 Yellow
4 Green
5 Purple
6 Black
;
ods layout gridded columns=3 rows=2 advance=bygroup;
proc sgplot data=_test noautolegend uniform=xscale dattrmap=mymap;
by grp;
series x=ind y=yvalue / group=grp lineattrs=( thickness=2 pattern=solid) attrid=grp;
refline 30/axis=x lineattrs=(color=red thickness=2 pattern=solid);
run;
ods layout end;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.