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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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;

View solution in original post

2 REPLIES 2
Jay54
Meteorite | Level 14

I suggest you set LineColor and FillColor in the attrmap in addition to MarkerColor.  BarCharts use the fill color, and regression lines use LineColor.

DanH_sas
SAS Super FREQ

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1458 views
  • 0 likes
  • 3 in conversation