BookmarkSubscribeRSS Feed
jksthomas
Calcite | Level 5

Hi Experts, 

 

I am trying to create a vital signs graph by each parameter like temp, weight in each page per treatment group (total 5 TRTGRPs).  I have problem in assigning colors and creating sgplot xaxistable even after using discrete table for assigning attributes consistently.

 

When all 5 TRTGRPS are present for a particular parameter, colors are assigned properly (Eg: Page2). However, when a TRTGRP is missing, color gets replaced with the missing ones and this causes misrepresentation in graph (Eg: page2). Is there a way to avoid this overlapping of color when any other class (treatment group is missing).

 

 

Please note: TRTGRP3 is missing at page 1 and TRTGRP4 picks green color, but it is supposed to be purple as per TRT order.

jksthomas_1-1682603641325.png

 

data discgrp;
retain id "discgrp" linecolor "black" ;
length fillcolor $20;
value='TRTGRP1'; fillcolor='red'; output;
value='TRTGRP2'; fillcolor='blue'; output;
value='TRTGRP3'; fillcolor='green'; output;
value='TRTGRP4'; fillcolor='purple'; output;
value='TRTGRP5'; fillcolor='black'; output;
run;

 

 

6 REPLIES 6
jksthomas
Calcite | Level 5

Thanks @PaigeMiller for your inputs. I have used the same discrete attrib map to pick pick up the attibutes. however if one value is missed out, next value picks up the color of the missed one.

 

Eg: from the link you shared.

If graph is breakdown into 2 page and one page have 2 values both "M" and "F", but the second page of graph has only "F", "F" picks up the color of "M" even after assigning discrete attribute mapping. Is there any option to prevent it?  

yabwon
Meteorite | Level 14

Are you sure you don't have some mismatch in values assignment? 

I did some tests and it picks up colours properly.

Bart

data myattrmap;
  id="myid"; value="M";
  linecolor="blue"; fillcolor="blue";
  textcolor="blue"; textstyle="normal";
  textweight="normal";
output;

id="myid"; value="F";
  linecolor="red"; fillcolor="pink";
  textcolor="red"; textstyle="italic";
  textweight="bold";
output;

id="myid"; value="U";
  linecolor="green"; fillcolor="yelow";
  textcolor="green"; textstyle="italic";
  textweight="bold";
output;

run;


data class; 
set 
sashelp.class(in=a)
sashelp.class(in=u1)
sashelp.class(in=b where=(sex="M"))
sashelp.class(in=c where=(sex="F"))
;
if u1 then sex="U";
grp=b+2*c;

output;

if b then do;
  sex="U";
  output;
end;
run;

ods PDF file="C:\test.pdf";
proc sgplot data=class dattrmap=myattrmap;
  by grp;
  vbar age / response=height group=sex stat=mean
     groupdisplay=cluster attrid=myid;
  xaxistable weight / textgroup=sex 
     textgroupid=myid;
run;

ods PDF close;

yabwon_0-1682666857670.png

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Meteorite | Level 14

Sorry typo in this part:

data myattrmap;
  length linecolor fillcolor textcolor $ 10;

  id="myid"; value="M";
  linecolor="blue"; fillcolor="blue";
  textcolor="blue"; textstyle="normal";
  textweight="normal";
output;

id="myid"; value="F";
  linecolor="red"; fillcolor="pink";
  textcolor="red"; textstyle="italic";
  textweight="bold";
output;

  id="myid"; value="U";
  linecolor="green"; fillcolor="yellow";
  textcolor="green"; textstyle="italic";
  textweight="bold";
output;

run;
proc print;
run;

yabwon_0-1682667293619.png

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



PaigeMiller
Diamond | Level 26

Agreeing with @yabwon , the discrete attribute maps eliminate this problem of different categories missing in different plots. Not only has that been my own experience in this situation, but SAS says it will do that in the documentation (which I trust highly — that doesn't mean there has never been mistakes in the documentation, but when they say something will work, and I get it to work, which is 99.9% or more of the time, I have tremendous confidence in the documentation).

--
Paige Miller
jksthomas
Calcite | Level 5

Thanks a lot @yabwon and @PaigeMiller for your inputs. Let me check again my codes and get back on outcome. Thanks again 🙂

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 194 views
  • 4 likes
  • 3 in conversation