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.
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;
....using SAS 9.3.
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;
Brilliant. Thanks. that worked perfectly.
See new blog article.
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: