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

 

Hi

  I have made this following figure. Im quite unsure how to do the legend as one box for blue and one box for red .I get this colurs from colorresponse but my group variable is different. Can some one plz help?

My code below:

 

 

Manj_0-1677520548544.png

 


proc template;
define statgraph bw_profile;
dynamic title;
begingraph / designwidth=1100 designheight=640 border = off;
entrytitle "Figure 1" / textattrs=(color=black family="Courier New" size=9pt weight=normal);
entrytitle "xxxxxxxxxxx " / textattrs=(color=black family="Courier New" size=9pt weight=normal);
entrytitle "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" / textattrs=(color=black family="Courier New" size=9pt weight=normal);
entryfootnote halign = left " " /textattrs=(size=8 ) ;
entryfootnote halign = left " " /textattrs=(size=8 ) ;
entryfootnote halign = left " " /textattrs=(size=8 ) ;
entryfootnote halign = left "MFSAF = Myelofibrosis Symptom Assessment Form (MFSAF) V4.0; OL = Open Label."/ textattrs=(color=black family="Courier New" size=9pt weight=normal);
entryfootnote halign = left "Program: f_xx_ab48_ir.sas" halign=right " Page 1 of 1" / textattrs=(color=black family="Courier New" size=9pt weight=normal) ;

layout lattice / rowdatarange=data columns=1 rows=2 rowweights = (.95 .05);

layout overlay / cycleattrs=true
yaxisopts = (label = 'Change from Baseline, %' offsetmin = 0.015 offsetmax = 0.015
linearopts = (tickvalueformat=ytfmt. viewmin =-100 viewmax = 100 tickvaluesequence=(start=-100 end=100 increment=10)))
xaxisopts = (display=none);
barchart category=id response=pchg / group=ESMMB groupdisplay=cluster colorresponse=resp colormodel=(blue red)
name='waterfall' /*dataskin=gloss filltype=gradient*/
barlabelattrs=(size=6pt weight=bold)
fillattrs=(color=gray)
outlineattrs=(color=gray)
clusterwidth=0.8;
referenceline y=-50/ lineattrs=(pattern=mediumdash) ;
referenceline x=&yref / lineattrs=(pattern=mediumdash);
endlayout;


layout overlay / cycleattrs=true
xaxisopts = (display=none)
yaxisopts = (display=none) walldisplay = none;
seriesplot x=id y=myy/lineattrs=(thickness = 0);
drawtext "&danlbl (N= %left(&pop3))" /y=1 x=8 width=18 xspace=wallpercent;
drawtext "&mmblbl (N= %left(&pop2))" /y=1 x=45 width=18 xspace=wallpercent;
endlayout;

endlayout;
endgraph;
end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Without data or the values of some macro variables much less an Sgrender call I cannot test any code.

I think that if you modify this:

barchart category=id response=pchg / group=ESMMB groupdisplay=cluster colorresponse=resp colormodel=(blue red)
name='waterfall' /*dataskin=gloss filltype=gradient*/
barlabelattrs=(size=6pt weight=bold)
fillattrs=(color=gray)
outlineattrs=(color=gray)
clusterwidth=0.8;

to add a Name that a Discretelegend statement can associate with your chart such as

barchart category=id response=pchg / group=ESMMB groupdisplay=cluster colorresponse=resp colormodel=(blue red)
name='waterfall' /*dataskin=gloss filltype=gradient*/
barlabelattrs=(size=6pt weight=bold)
fillattrs=(color=gray)
outlineattrs=(color=gray)
clusterwidth=0.8
name='bars';

discretelegend 'bars';

That you will get a default legend. Add options to discretelegend as needed.

 

Note: it is a good idea to paste code into a text box opened on the forum with the </> icon above the message window to preserver formatting.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Without data or the values of some macro variables much less an Sgrender call I cannot test any code.

I think that if you modify this:

barchart category=id response=pchg / group=ESMMB groupdisplay=cluster colorresponse=resp colormodel=(blue red)
name='waterfall' /*dataskin=gloss filltype=gradient*/
barlabelattrs=(size=6pt weight=bold)
fillattrs=(color=gray)
outlineattrs=(color=gray)
clusterwidth=0.8;

to add a Name that a Discretelegend statement can associate with your chart such as

barchart category=id response=pchg / group=ESMMB groupdisplay=cluster colorresponse=resp colormodel=(blue red)
name='waterfall' /*dataskin=gloss filltype=gradient*/
barlabelattrs=(size=6pt weight=bold)
fillattrs=(color=gray)
outlineattrs=(color=gray)
clusterwidth=0.8
name='bars';

discretelegend 'bars';

That you will get a default legend. Add options to discretelegend as needed.

 

Note: it is a good idea to paste code into a text box opened on the forum with the </> icon above the message window to preserver formatting.

 

Manj
Fluorite | Level 6

Thanks @ballardw . I used legenditem and discretelegend and it worked.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 664 views
  • 0 likes
  • 2 in conversation