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

Can you please advise how to clip a wide confidence interval in a forest plot? I am creating a forest plot and one of the variables had a wide 95% CL and would like to cut off the upper limit and show it by an arrow or by a continous indicator > etc...

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You don't say exactly which value you want to clip or what to. That would be a basic change of the value from the one you are currently plotting.

 

The possibilities with errorbars for changing only one value cap (which I think would be involved) would require an additional SCATTER statement with perhaps NOERRORBARCAPS and different X and Y variables so not confused with the other Scatter statements. Then either an additional Scatter with marker symbol like TriangleLeft or Triangleright, or the filled versions or even a GreaterThan or LessThan appearing at the position of the upper or lower error limit (i.e. where you want the arrow-like symbol to appear).

 

Curious as to why the concern though. The graph I get looks just fine. I'm not at all sure that the extra work is really worth much.

View solution in original post

4 REPLIES 4
ballardw
Super User

Data please, in the form of a data step.

And the current code you are using to create your plot.

 

There are enough different ways to create any given plot that we need details to address your specific problem. Without data we can't test if the code does what is needed.

Abimal_Zippi
Fluorite | Level 6

Thanks, I am trying to replicate the following code from Paper Template (sas.com)

Here are the codes from this page:

data forestg;
length SUBGP TEXT $14;
infile datalines delimiter=",";
input SUBGP $ IND N EPCT UPCT RR LCL UCL PVAL TVAR TEXT $ XP YP TID BAND;
datalines;
Age,0,.,.,.,.,.,.,0.004,1, ,.,.,1,.
< 13 Years,1,500,50.0,48.0,1.04,0.87,1.25,.,2, ,.,.,2,.
=> 13 Years,1,520,73.1,57.7,1.27,1.11,1.44,.,3, ,.,.,2,.
Sex,0,.,.,.,.,.,.,0.75,4, ,.,.,1,4
Female,1,500,54.4,49.2,1.11,0.93,1.31,.,5, ,.,.,2,5
Male,1,520,45.8,48.9,0.94,0.78,1.12,.,6, ,.,.,2,6
Ethnicity,0,.,.,.,.,.,.,0.35,7, ,.,.,1,.
Hispanic,1,80,60,46,1.30,0.86,1.98,.,8, ,.,.,2,.
Non-Hispanic,1,940,47.7,51.7,0.92,0.82,1.04,.,9, ,.,.,2,.
Length of Stay,0,.,.,.,.,.,.,0.0001,10, ,.,.,1,10
< 2 Days,1,484,50.4,57.9,0.87,0.74,1.03,.,11, ,.,.,2,11
=> 2 Days,1,536,41.5,57.4,0.72,0.61,0.86,.,12, ,.,.,2,12
Comorbidities,0,.,.,.,.,.,.,0.86,13, ,.,.,1,.
Yes,1,40,33.3,35.9,0.93,0.27,2.25,.,14, ,.,.,2,.
No,1,980,49.6,49.0,1.01,0.89,1.15,.,15, ,.,.,2,.
,.,.,.,.,.,.,.,.,16,Less Risk,0.4,16,2,.
,.,.,.,.,.,.,.,.,16,More Risk,1.8,16,2,.
;
run;

data forestmap2;
input ID $ value textcolor $ textsize textweight $;
datalines;
myid 1 black 7 bold
myid 2 black 5 normal
;
run;

proc sgplot data=forestg noautolegend dattrmap=forestmap2 ;
styleattrs axisextent=data;
refline BAND / lineattrs=(thickness=23 color=palegreen);
scatter x=RR y=TVAR / markerattrs=(symbol=squarefilled color=forestgreen)
xerrorlower=LCL xerrorupper=UCL errorbarattrs=(color=forestgreen);
scatter x=RR y=TVAR / markerattrs=(size=0) x2axis;
refline 1 / axis=x lineattrs=(color=forestgreen);
text x=XP y=TVAR text=TEXT / position=center;
yaxistable SUBGP / location=inside position=left textgroupid=myid textgroup=TID
labelattrs=(size=10 weight=bold) indentweight=IND nomissingchar label="Subgroup";
yaxistable N / location=inside position=left labelattrs=(size=10 weight=bold)
valueattrs=(size=7) nomissingchar label="Count";
yaxistable EPCT / location=inside position=right labelattrs=(size=10 weight=bold)
valueattrs=(size=7) nomissingchar label="Exposed";
yaxistable UPCT / location=inside position=right labelattrs=(size=10 weight=bold)
valueattrs=(size=7) nomissingchar label="Not Exposed";
yaxistable PVAL / location=inside position=right labelattrs=(size=10 weight=bold)
valueattrs=(size=7) nomissingchar label="P-Value";
yaxis reverse display=none colorbands=odd colorbandsattrs=(color=palegreen
transparency=0.5) offsetmin=0;
xaxis display=(nolabel) values=(0 to 2.5 by 0.5);
x2axis label="Risk Ratio" labelattrs=(size=10 weight=bold) display=(noline noticks
novalues);
run;

I would like to clip the comorbidity 'Yes' subgroup confidence interval [i.e. 0.27 - 2.25]

 

ballardw
Super User

You don't say exactly which value you want to clip or what to. That would be a basic change of the value from the one you are currently plotting.

 

The possibilities with errorbars for changing only one value cap (which I think would be involved) would require an additional SCATTER statement with perhaps NOERRORBARCAPS and different X and Y variables so not confused with the other Scatter statements. Then either an additional Scatter with marker symbol like TriangleLeft or Triangleright, or the filled versions or even a GreaterThan or LessThan appearing at the position of the upper or lower error limit (i.e. where you want the arrow-like symbol to appear).

 

Curious as to why the concern though. The graph I get looks just fine. I'm not at all sure that the extra work is really worth much.

Abimal_Zippi
Fluorite | Level 6

Thanks, @ballardw. And sorry, I wanted to clip the upperCL 2.25. You are right there is no problem with this graph. As I mentioned in my question, I am experimenting with this data to clip a value and add a marker symbol at the end (">". 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 1442 views
  • 1 like
  • 2 in conversation