Data visualization with SAS programming

justfiying text on a forest plot

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

justfiying text on a forest plot


I have a forest plot and hanving read the previous papers about indenting text and the subgroup issue I have a fairly similar piece of code to everyone else. However, even though Im using a non-proportional font (as per other example) and output to pdf rather than doc, Im still getting my columns centre justified.

any help would be appreciated. Ive attached the code, pdf and png file.

Thanks.

Attachment
Attachment

Accepted Solutions
Solution
‎01-29-2014 12:05 PM
SAS Super FREQ
Posts: 1,044

Re: justfiying text on a forest plot

When you use the MARKERCHARACTER to display such labels, the text string is always placed center justified with the location of the marker (not drawn).  So, you would have to jump through some hoops to get the alignment you want, even with the non-proportional fonts.

However, with SAS 9.3, you have more options.  SAS 9.3 supports a user specified data label position for the scatter plot.  So, instead of using MarkerCharacter, change you code to use regular scatterplot with DataLabel.  Use  DataLabelPosition =LEFT or RIGHT or CENTER as needed.  Proportional fonts will be OK.  Set marker size to zero.  Here is some sample code.

proc template;
  define statgraph datalabel;
    dynamic _pos;
    begingraph;
      entrytitle 'Weight by Height for all Students';
      layout overlay;
        scatterplot x=sex y=weight / datalabel=name datalabelposition=_pos markerattrs=(size=0); 
      endlayout;
    endgraph;
  end;
run;


ods graphics / reset width=5in height=3in imagename='datalabel_left';
proc sgrender data=sashelp.class template=datalabel;
  dynamic _pos='left';
run;

ods graphics / reset width=5in height=3in imagename='datalabel_right';
proc sgrender data=sashelp.class template=datalabel;
  dynamic _pos='right';
run;

datalabel_right1.png

View solution in original post


All Replies
Contributor
Posts: 24

Re: justfiying text on a forest plot

....using SAS 9.3.

Solution
‎01-29-2014 12:05 PM
SAS Super FREQ
Posts: 1,044

Re: justfiying text on a forest plot

When you use the MARKERCHARACTER to display such labels, the text string is always placed center justified with the location of the marker (not drawn).  So, you would have to jump through some hoops to get the alignment you want, even with the non-proportional fonts.

However, with SAS 9.3, you have more options.  SAS 9.3 supports a user specified data label position for the scatter plot.  So, instead of using MarkerCharacter, change you code to use regular scatterplot with DataLabel.  Use  DataLabelPosition =LEFT or RIGHT or CENTER as needed.  Proportional fonts will be OK.  Set marker size to zero.  Here is some sample code.

proc template;
  define statgraph datalabel;
    dynamic _pos;
    begingraph;
      entrytitle 'Weight by Height for all Students';
      layout overlay;
        scatterplot x=sex y=weight / datalabel=name datalabelposition=_pos markerattrs=(size=0); 
      endlayout;
    endgraph;
  end;
run;


ods graphics / reset width=5in height=3in imagename='datalabel_left';
proc sgrender data=sashelp.class template=datalabel;
  dynamic _pos='left';
run;

ods graphics / reset width=5in height=3in imagename='datalabel_right';
proc sgrender data=sashelp.class template=datalabel;
  dynamic _pos='right';
run;

datalabel_right1.png

Contributor
Posts: 24

Re: justfiying text on a forest plot

Brilliant. Thanks. that worked perfectly.

SAS Super FREQ
Posts: 1,044

Re: justfiying text on a forest plot

Post a Question
Discussion Stats
  • 4 replies
  • 565 views
  • 0 likes
  • 2 in conversation