This is kind of related to an earlier question I had because I'm sure some of you contributors saw it. Basically I am generating a box chart and a regression plot but I want to keep the colors consistent. I am generating a lot of them and I noticed on some graphs the color would be reversed aka in the box chart red = 0, blue = 1, while in the regression plot red = 1 and blue = 0. I tried to make an ATTRMAP file but for some reason this made some of the regression colors GREEN instead of blue and I don't understand why, while in the bar chart nothing really changed.
%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue "; output;
Value = '1'; MarkerColor = "Red "; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;
In the part of the macro, the issue occured with certain SNPs that I ran this through. Some of the graphs looked fine (aka consistent color between the bar chart and regression plot), but as mentioned before some of the "blue" lines turned "Green". Before I added in the dattrmap statement I had an issue with inconsistent colors.
You haven't defined the colors for the other plot features. Try this:
%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue"; FillColor="Blue"; LineColor="Blue"; output;
Value = '1'; MarkerColor = "Red"; FillColor="Red"; LineColor="Red"; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;
I suggest you set LineColor and FillColor in the attrmap in addition to MarkerColor. BarCharts use the fill color, and regression lines use LineColor.
You haven't defined the colors for the other plot features. Try this:
%Macro plots(data, cholinevar, response, SNP, title);
data Attrmap;
ID = "&SNP";
Value = '0'; MarkerColor = "Blue"; FillColor="Blue"; LineColor="Blue"; output;
Value = '1'; MarkerColor = "Red"; FillColor="Red"; LineColor="Red"; output;
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
vbar &cholinevar._4 / response = &response stat = mean group = &SNP groupdisplay = cluster limitstat = stderr attrid = &SNP;
title "&title";
run;
PROC sGPLOT DATA = &data noautolegend dattrmap = attrmap;
reg x = &cholinevar y = &response /group = &SNP clm attrid = &SNP;
title "&title";
run;
%mend plots;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.