BookmarkSubscribeRSS Feed
Crystal_F
Quartz | Level 8

Hi,

I have a problem having same color for each group when generating multiple figurs. Below is my program. I've also tried reset attrpriority=color, which didn't work neither in SAS studio.

proc format;
value Cat_raceeth 2='NON-H Caucasian' 3='NON-H African American' 4='NON-H Asian' 1= 'Hispanic' 5='Other/Unknow';
run;

data myattrmap;
  id="myid"; value=1;
  linecolor="B"; fillcolor="B";
  textcolor="B"; textstyle="normal";
  textweight="normal";
output;

id="myid"; value=2;
  linecolor="R"; fillcolor="R";
  textcolor="R"; textstyle="normal";
  textweight="normal";
output;

id="myid"; value=3;
  linecolor="Y"; fillcolor="Y";
  textcolor="Y"; textstyle="normal";
  textweight="normal";
output;


run;

ods listing gpath = '/Volumes/data/Output/Deliveries063022/Fig';
ods graphics/imagename="Test" imagefmt=png ;
title "Distribution of HbA1C lab result in the last year of follow-up";
title2 "Non-H Caucasian vs. Hispanic";


proc sgplot data=data.descriptives (where=(test_result_A1Clst between 4 and 14 and Cat_raceeth in (1, 2))) dattrmap=myattrmap;   
    histogram test_result_a1clst / group =Cat_raceeth binstart=4 binwidth=0.5 showbins transparency=0.7 attrid=myid;
run;

ods graphics/imagename="Test2" imagefmt=png;
title "Distribution of HbA1C lab result in the last year of follow-up";
title2 "Non-H Caucasian vs. Non-H Black";


proc sgplot data=data.descriptives (where=(test_result_A1Clst between 4 and 14 and Cat_raceeth in (2, 3))) dattrmap=myattrmap;   
    histogram test_result_a1clst / group =Cat_raceeth binstart=4 binwidth=0.5 showbins transparency=0.7 attrid=myid;
run;

ods graphics off;

Note from SAS: 

NOTE: ODS statements in the SAS Studio environment may disable some output features.

 

The histogram ended up with blue and red for each figure. 

Any suggestion would be helpful! Thanks.

4 REPLIES 4
DanH_sas
SAS Super FREQ

Without seeing your data to be sure, I would say that the issue is that formatted values of your "cat_raceeth" group variable do not match the values in your attrmap data set. Also, the "value" column should be character, so you should put those values in quotes.

 

Hope this helps!

Dan

Crystal_F
Quartz | Level 8

Good catch! But unfortunately, it didn't work when I fixed as you suggested. I guess the order of color is set by default and hard to change in SAS studio?

DanH_sas
SAS Super FREQ

Sorry, just looking at this again. I see the VALUE in you attrmap is formatted into a string by your user-defined format. Therefore, the VALUE in the attrmap needs to be the strings from the format, not the number.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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