Hello Everyone,
I am trying to produce this graph below with the following data
block | Count | Percent | Category | Type |
1 | 5 | 9% | AnyChronicGap | Per Patients |
1 | 24 | 23% | AnyChronicGap | Per Veins |
1 | 648 | 78% | AnyChronicGap | Per Segments |
1 | 5 | 9% | ChronicGap | Per Patients |
1 | 24 | 23% | ChronicGap | Per Veins |
1 | 648 | 78% | ChronicGap | Per Segments |
1 | 11 | 21% | AcuteGap | Per Patients |
1 | 41 | 39% | AcuteGap | Per Veins |
1 | 725 | 88% | AcuteGap | Per Segments |
Below is the code that generates my current graph
proc sgplot data=have;
vbar category /group=Type CLUSTERWIDTH=.8 groupdisplay=cluster response=Percent daTALABEL ;
keylegend / location=inside position=topright;
xaxis display=(nolabel);
yaxis values = (0 to 1 by .2) label=" ";
xaxistable COUNT;
run;
But i am trying to reach this final output or something close to it.
Thanks for your help.
Tim
data have;
infile cards expandtabs truncover;
input block Count Percent :percent8. Category :$20. Type $20.;
type1+1;
format percent percent5.0;
cards;
1 5 9% AnyChronicGap Per Patients
1 24 23% AnyChronicGap Per Veins
1 648 78% AnyChronicGap Per Segments
1 5 9% ChronicGap Per Patients
1 24 23% ChronicGap Per Veins
1 648 78% ChronicGap Per Segments
1 11 21% AcuteGap Per Patients
1 41 39% AcuteGap Per Veins
1 725 88% AcuteGap Per Segments
;
%sganno
data sganno;
%SGRECTANGLE(X1=23,Y1=92.5,HEIGHT=18,WIDTH=20,DISPLAY="ALL",DRAWSPACE="LAYOUTPERCENT",FILLCOLOR="white",LINECOLOR="black",LINETHICKNESS=1)
%SGTEXT(LABEL="PVI Durability",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",TEXTSIZE=10,X1=22,Y1=99,FILLCOLOR="white",FILLTRANSPARENCY=1)
%SGRECTANGLE(X1=15,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXFEE0D2" ,LINECOLOR="white",RESET="ALL")
%SGRECTANGLE(X1=16.5,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXDEEBF7" ,LINECOLOR="white")
%SGRECTANGLE(X1=18,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXE5F5E0" ,LINECOLOR="white")
%SGTEXT(LABEL="per PV",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=95,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGRECTANGLE(X1=14.5,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXFC9272" ,LINECOLOR="white")
%SGRECTANGLE(X1=16,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX9ECAE1" ,LINECOLOR="white")
%SGRECTANGLE(X1=17.5,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXA1D99B" ,LINECOLOR="white")
%SGTEXT(LABEL="median PV",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=91,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGRECTANGLE(X1=14.5,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXDE2D26" ,LINECOLOR="white")
%SGRECTANGLE(X1=16,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX3182BD" ,LINECOLOR="white")
%SGRECTANGLE(X1=17.5,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX31A354" ,LINECOLOR="white")
%SGTEXT(LABEL="per Patient",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=87,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGPOLYGON( X1=15, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=35,Y1=5)
%SGPOLYCONT(X1=40,Y1=10)
%SGPOLYCONT(X1=35,Y1=15)
%SGPOLYCONT(X1=15,Y1=15)
%SGPOLYCONT(X1=20,Y1=10)
%SGPOLYGON( X1=45, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=65,Y1=5)
%SGPOLYCONT(X1=70,Y1=10)
%SGPOLYCONT(X1=65,Y1=15)
%SGPOLYCONT(X1=45,Y1=15)
%SGPOLYCONT(X1=50,Y1=10)
%SGPOLYGON( X1=75, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=95,Y1=5)
%SGPOLYCONT(X1=100,Y1=10)
%SGPOLYCONT(X1=95,Y1=15)
%SGPOLYCONT(X1=75,Y1=15)
%SGPOLYCONT(X1=80,Y1=10)
%SGTEXT(LABEL="Monophasic (11pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CXDE2D26",X1=30,Y1=10,FILLTRANSPARENCY=1,RESET="ALL")
%SGTEXT(LABEL="Early/Other Bisphasic (55pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CX3182BD",X1=60,Y1=10,FILLTRANSPARENCY=1)
%SGTEXT(LABEL="Optimized Biphasic (44pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CX31A354",X1=90,Y1=10,FILLTRANSPARENCY=1)
run;
proc sgplot data=have noautolegend noborder pad=(bottom=80) sganno=sganno;
styleattrs datacolors=(CXFEE0D2 CXFC9272 CXDE2D26
CXDEEBF7 CX9ECAE1 CX3182BD
CXE5F5E0 CXA1D99B CX31A354 )
datacontrastcolors=(CXDE2D26 CXDE2D26 CXDE2D26
CX3182BD CX3182BD CX3182BD
CX31A354 CX31A354 CX31A354 );
vbarparm category=category response=Percent/group=Type1 CLUSTERWIDTH=.8
groupdisplay=cluster nooutline baseline=0 ;
text x=category y=percent text=Percent/group=Type1 strip textattrs=(size=10)
contributeoffsets=none position=top groupdisplay=cluster;
yaxis values = (0 to 1 by .2) max=1 valueshint label="Durability on Rem(%)" grid display=(noline noticks);
xaxis display=none;
run;
data have;
infile cards expandtabs truncover;
input block Count Percent :percent8. Category :$20. Type $20.;
type1+1;
format percent percent5.0;
cards;
1 5 9% AnyChronicGap Per Patients
1 24 23% AnyChronicGap Per Veins
1 648 78% AnyChronicGap Per Segments
1 5 9% ChronicGap Per Patients
1 24 23% ChronicGap Per Veins
1 648 78% ChronicGap Per Segments
1 11 21% AcuteGap Per Patients
1 41 39% AcuteGap Per Veins
1 725 88% AcuteGap Per Segments
;
%sganno
data sganno;
%SGRECTANGLE(X1=23,Y1=92.5,HEIGHT=18,WIDTH=20,DISPLAY="ALL",DRAWSPACE="LAYOUTPERCENT",FILLCOLOR="white",LINECOLOR="black",LINETHICKNESS=1)
%SGTEXT(LABEL="PVI Durability",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",TEXTSIZE=10,X1=22,Y1=99,FILLCOLOR="white",FILLTRANSPARENCY=1)
%SGRECTANGLE(X1=15,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXFEE0D2" ,LINECOLOR="white",RESET="ALL")
%SGRECTANGLE(X1=16.5,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXDEEBF7" ,LINECOLOR="white")
%SGRECTANGLE(X1=18,Y1=95,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXE5F5E0" ,LINECOLOR="white")
%SGTEXT(LABEL="per PV",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=95,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGRECTANGLE(X1=14.5,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXFC9272" ,LINECOLOR="white")
%SGRECTANGLE(X1=16,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX9ECAE1" ,LINECOLOR="white")
%SGRECTANGLE(X1=17.5,Y1=91,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXA1D99B" ,LINECOLOR="white")
%SGTEXT(LABEL="median PV",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=91,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGRECTANGLE(X1=14.5,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CXDE2D26" ,LINECOLOR="white")
%SGRECTANGLE(X1=16,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX3182BD" ,LINECOLOR="white")
%SGRECTANGLE(X1=17.5,Y1=87,HEIGHT=3,WIDTH=1,DISPLAY="FILL",DRAWSPACE="LAYOUTPERCENT" ,FILLCOLOR="CX31A354" ,LINECOLOR="white")
%SGTEXT(LABEL="per Patient",WIDTH=100,DRAWSPACE="LAYOUTPERCENT",ANCHOR="LEFT",TEXTSIZE=10,X1=19,Y1=87,TEXTSTYLE="ITALIC",FILLCOLOR="white")
%SGPOLYGON( X1=15, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=35,Y1=5)
%SGPOLYCONT(X1=40,Y1=10)
%SGPOLYCONT(X1=35,Y1=15)
%SGPOLYCONT(X1=15,Y1=15)
%SGPOLYCONT(X1=20,Y1=10)
%SGPOLYGON( X1=45, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=65,Y1=5)
%SGPOLYCONT(X1=70,Y1=10)
%SGPOLYCONT(X1=65,Y1=15)
%SGPOLYCONT(X1=45,Y1=15)
%SGPOLYCONT(X1=50,Y1=10)
%SGPOLYGON( X1=75, Y1=5,DRAWSPACE="GRAPHPERCENT" ,LINECOLOR="black",DISPLAY="ALL",LINETHICKNESS=1)
%SGPOLYCONT(X1=95,Y1=5)
%SGPOLYCONT(X1=100,Y1=10)
%SGPOLYCONT(X1=95,Y1=15)
%SGPOLYCONT(X1=75,Y1=15)
%SGPOLYCONT(X1=80,Y1=10)
%SGTEXT(LABEL="Monophasic (11pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CXDE2D26",X1=30,Y1=10,FILLTRANSPARENCY=1,RESET="ALL")
%SGTEXT(LABEL="Early/Other Bisphasic (55pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CX3182BD",X1=60,Y1=10,FILLTRANSPARENCY=1)
%SGTEXT(LABEL="Optimized Biphasic (44pts)",WIDTH=14,DRAWSPACE="GRAPHPERCENT",TEXTSIZE=10,TEXTCOLOR="CX31A354",X1=90,Y1=10,FILLTRANSPARENCY=1)
run;
proc sgplot data=have noautolegend noborder pad=(bottom=80) sganno=sganno;
styleattrs datacolors=(CXFEE0D2 CXFC9272 CXDE2D26
CXDEEBF7 CX9ECAE1 CX3182BD
CXE5F5E0 CXA1D99B CX31A354 )
datacontrastcolors=(CXDE2D26 CXDE2D26 CXDE2D26
CX3182BD CX3182BD CX3182BD
CX31A354 CX31A354 CX31A354 );
vbarparm category=category response=Percent/group=Type1 CLUSTERWIDTH=.8
groupdisplay=cluster nooutline baseline=0 ;
text x=category y=percent text=Percent/group=Type1 strip textattrs=(size=10)
contributeoffsets=none position=top groupdisplay=cluster;
yaxis values = (0 to 1 by .2) max=1 valueshint label="Durability on Rem(%)" grid display=(noline noticks);
xaxis display=none;
run;
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!
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.