BookmarkSubscribeRSS Feed
raja777pharma
Fluorite | Level 6

Hi,

I am trying to genrate the waterfall plot , but in data there is no all legend vlauee and only diaplay in legend what are in data.

But i need to display all values which are defined in proc format.

 

Below is sample output :

 

raja777pharma_0-1763006059514.png

 

 

My Code is  :

 

ods listing close;
ods graphics on / border=off width=22.86cm height=9.5cm;

   proc sgplot data=final noborder noautolegend;
   by trt01a;
    format resp $rsf.;
    refline -50 / axis=y lineattrs=(pattern=shortdash);

	vbar subjid/response = pchg categoryorder=RESPDESC group=resp;

	xaxis label = "Patient Number" fitpolicy = ROTATE;
	yaxis label = "Maximum Percent Reduction from Baseline in SPD" min=&minp. max=&maxp. values=(-120 to 50 by 20);

   keylegend /title = 'IPCGS' location=inside position=topright;
run;

ods rtf close;
ods listing;
ods graphics off;

My current output : add one more group that is "PD" progressive disease 

 

raja777pharma_1-1763006151002.png

 

How to display this water fall as per sample display 

 

Thank you.

Raja

 

2 REPLIES 2
DanH_sas
SAS Super FREQ

You can use a discrete attributes map to do it. You can use the map to control both the attributes for the plot , as well as whether the legend content is driven by the map instead of the data. This last behavior is controlled by the SHOW=ATTRMAP option in the map data. Here is a simple example of a map using the active style's attributes but using SHOW=ATTRMAP to have its content used for the legend. In your case, put all five possible responses in the map.

data attrmap;
    retain ID "myid" show "attrmap";
    length value $ 7 fillstyleelement $ 10 linestyleelement $ 10; 
    input value $ fillstyleelement $ linestyleelement $;
    cards;
    M       GraphData1 GraphData1
    F       GraphData2 GraphData2
    Unknown GraphData3 GraphData3
    ;
run;

proc sgplot data=sashelp.class dattrmap=attrmap;
    vbar age / response=weight group=sex groupdisplay=cluster stat=mean attrid=myid;
run;

attrmap.png

Ksharp
Super User

Another workaround way is using LEGENDITEM statement.


proc sgplot data=sashelp.class;
    vbar age / response=weight group=sex groupdisplay=cluster stat=mean name='x';
	legenditem name='u' type=fill/fillattrs=(color=gray) label='Unknown';
	keylegend 'x' 'u';
run;

Ksharp_0-1763020082051.png

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 247 views
  • 6 likes
  • 3 in conversation