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


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.


SGRender24.png
1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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

4 REPLIES 4
Adie_efc
Calcite | Level 5

....using SAS 9.3.

Jay54
Meteorite | Level 14

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

Adie_efc
Calcite | Level 5

Brilliant. Thanks. that worked perfectly.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 1591 views
  • 0 likes
  • 2 in conversation