Data visualization with SAS programming

ForestPlot with PROC TEMPLATE: indentation issue and group attributes

Accepted Solution Solved
Reply
Super Contributor
Posts: 543
Accepted Solution

ForestPlot with PROC TEMPLATE: indentation issue and group attributes

Hello SAS Experts, Masters and Gurus!

I am trying to create a forestplot-like graph, using PROC TEMPLATE.

Most things work as I expect to work.

However, I have 2 questions:

(1) I would like to ident the "subgroup" labels on the y-axis, like this:

Gender

     Male

     Female

...

(2) I would like the lines (mean +/- s.e.) to alternate between solid and dashed (so, gender has lines black and solid, race has lines gray and dashed...)

My code is below and the sample data is attached:

/*hoping to get the leading-blanks to stay in the format*/

data _null_;
       call symput('blk','A0'X);
run;


proc format;
value $ lab
  'Male' = "&blk.&blk.   Male"
  'Female' = "&blk.&blk.   Female"
  'Black' = "&blk.&blk.   Black"
  'White' = "&blk.&blk.   Non-Black"
  ' 43 years' = "&blk.&blk.   43 years"
  ' 66 years' = "&blk.&blk.   66 years"
  ' 82 years' = "&blk.&blk.   82 years"
;
quit;


proc template;
define statgraph sgdesign;
dynamic _ESTIMATE _LABEL _GRP_VAR _ESTIMATE2 _UPPER _LOWER;
begingraph / designwidth=1408 designheight=807;
DiscreteAttrMap name="__ATTRMAP__";
   Value "1" / markerattrs=( color=black symbol=circle)
                    lineattrs=( color=black pattern=2);
   Value "2" / markerattrs=( color=grayaa symbol=plus)
                        lineattrs=( color=grayaa pattern=3);
   Value "3" / markerattrs=( color=black symbol=circle)
                       lineattrs=( color=black pattern=2);
EndDiscreteAttrMap;
DiscreteAttrVar attrvar=my_grp var=_grp_var attrmap="__ATTRMAP__";

   layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
      layout overlay / xaxisopts=( display=(TICKS TICKVALUES LINE LABEL )
            griddisplay=off
         label=('Mean (95% Confidence Interval) of eGFR Slope')
         labelattrs=(size=14 style=NORMAL weight=BOLD )
         tickvalueattrs=(size=14 ))
        yaxisopts=( reverse=true display=(TICKS TICKVALUES LINE )
         griddisplay=off
         labelattrs=GraphTitleText(size=14 )
         tickvalueattrs=(size=14 )
         gridattrs=(color=CX848284 pattern=2 thickness=1 ));
         scatterplot x=_ESTIMATE y=_LABEL /
     group=my_grp
     datalabel=_ESTIMATE2 datalabelposition=TOP DATALABELATTRS = (size = 14)
     xerrorupper=_UPPER xerrorlower=_LOWER
     name='scatter'
     markerattrs=(symbol=CIRCLEFILLED size=15 weight=bold )
     errorbarattrs=(thickness=2 );
  referenceline x = 0 / lineattrs = (thickness=3 pattern=2 color=CX848284);
      endlayout;
   endlayout;
endgraph;
end;
run;

proc sgrender data = have template = sgdesign;
dynamic _ESTIMATE = "ESTIMATE" _LABEL = "LABEL" _GRP_VAR = "'GRP_VAR'n"
   _ESTIMATE2 = "ESTIMATE" _UPPER = "UPPER" _LOWER = "LOWER";
run;


Thank you!!!!!

Attachment

Accepted Solutions
Solution
‎11-28-2012 03:50 PM
SAS Super FREQ
Posts: 3,221

Re: ForestPlot with PROC TEMPLATE: indentation issue and group attributes


All Replies
Solution
‎11-28-2012 03:50 PM
SAS Super FREQ
Posts: 3,221

Re: ForestPlot with PROC TEMPLATE: indentation issue and group attributes

Grand Advisor
Posts: 9,694

Re: ForestPlot with PROC TEMPLATE: indentation issue and group attributes

A quick and dirty way that often works when you want leading blanks displayed but SAS insists on removing them is to use a NULL character instead of a space. This  is the ASCII 255, I'll let you figure the hex, or can be entered in the editor by holding down the ALT key and typing 255 (on WINDOWS systems at least). If you use this approach I recommend documenting it as it isn't obvious what is going on.

Super Contributor
Posts: 543

Re: ForestPlot with PROC TEMPLATE: indentation issue and group attributes

Thank you, Rick! I've been trying to indent the forest plot for months!

:-)

Now it's indented!

Post a Question
Discussion Stats
  • 3 replies
  • 499 views
  • 4 likes
  • 3 in conversation