BookmarkSubscribeRSS Feed
Manj
Fluorite | Level 6

Hi,

   Im using this code to create the following plot in rtf. im using sas studio .0.

The issue i have are:

   1) need a couple of space between the blue and red bars (not individual bars). I tried clusterwidth and its not working.The vertical dashed line has to ob on the space between the blue group and red group.

   2)  I also need a label under each group just below the x axis line (not the legend) .

 

proc sgplot data=adtss2 noautolegend;
   vbar pos/ response=PCHG group=ESMMB GROUPDISPLAY=CLUSTER clusterwidth=1 barwidth=.8/*FILLATTRS = (COLOR=lightblue)*/ nooutline;
   refline 25,35 / axis=y lineattrs=(pattern=shortdash color=grey);
   refline &xref / axis=x lineattrs=(pattern=shortdash color=black);
   xaxis display =none;
   yaxis label="Change from baseline (%)" values= (-100 to 100 by 10) valuesdisplay=('<=100' '-90' '-80' '-70' '-60' '-50' '-40' '-30' '-20' '-10' '0' '10' '20' '30' '40' '50' '60' '70' '80' '90' '>=100') valueshint;
run;

 

 

Manj_1-1675794051546.png

 

Thanks

Manj

1 REPLY 1
Ksharp
Super User
/*
Why not try PROC SGPANEL ?

Next time if you want get answer,
It better to post some data to test your code.
*/
data have;
call streaminit(123);
 do id=1 to 100;
   sex=ifc(id<70,'M','F');
   p=rand('integer',-100,100);
   output;
 end;
run;
proc sort data=have;by descending sex descending p;run;
data want;
 set have end=last;
 by descending sex;
 output;
 if last.sex and not last then do;
   do id=99991 to 99999;
    p=0;output;
   end;
 end;
run;

proc sgplot data=want noautolegend;
vbarparm category=id response=p/group=sex ;
refline 99995/axis=x  lineattrs=(pattern=shortdash color=black);
xaxis display =(noticks novalues noline) discreteorder=data  
label='Treatment(N=44)                                                       Placebo(N=67)';
yaxis label="Change from baseline (%)" values= (-100 to 100 by 10) 
valuesdisplay=('<=100' '-90' '-80' '-70' '-60' '-50' '-40' '-30' '-20' 
  '-10' '0' '10' '20' '30' '40' '50' '60' '70' '80' '90' '>=100') ;
run;

Ksharp_0-1675856390308.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 890 views
  • 0 likes
  • 2 in conversation