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-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1207 views
  • 0 likes
  • 3 in conversation