Data visualization with SAS programming

sgplot datalabel font-size

Reply
Regular Contributor
Posts: 194

sgplot datalabel font-size

How do I increase the font-size of the datalabels (ie inj_yr)?
Thank you.

proc sgplot data=nu2s description="Plot";
band x=cnt upper=emp_upper lower=emp_lower /
transparency=.655 group=category name="bmi";
xaxis min=5 max=50 label='Injury' grid;
yaxis min=50 max=250 label='# Employees' grid;
keylegend "bmi" / position=bottomright location=outside across=4 title='Rate: ';
series x=inj_non y=emp_non / datalabel=inj_yr lineattrs=(pattern=solid thickness=2px)
markerattrs=(symbol=circlefilled ) markers group=job_class name="pts";
SAS Super FREQ
Posts: 864

Re: sgplot datalabel font-size

Currently, you can only do it through an ODS style. You can create a small style that inherits from the style you're using but only adjusts the datalabel font size. Here is an example:

[pre]
proc template;
define style styles.mystyle;
parent=styles.listing;
style GraphDataText from GraphDataText /
fontsize=9pt;
end;
run;
[/pre]

Then, you can set STYLE=MYSTYLE on the ODS destination statement and you should see the size increase. Let me know if you have any problems.

Thanks!
Dan
Regular Contributor
Posts: 194

Re: sgplot datalabel font-size

How do I combine mystyle with the style below:

proc template;
define style styles.rate;
parent=styles.analysis;
style graphcolors from graphcolors /
'gdata1'=MOYG
'gdata2'=STY
'gdata3'=BILG
'gdata4'=LILG
'gdata5'=VLIBG
'gdata6'=VIPK
'gdata7'=VIYPK
'gdata8'=LIRP;
'gdata9'=LIV;
end;quit;
SAS Super FREQ
Posts: 864

Re: sgplot datalabel font-size

Just add the GraphDataText to your style:

[pre]
proc template;
define style styles.rate;
parent=styles.analysis;
style graphcolors from graphcolors /
'gdata1'=MOYG
'gdata2'=STY
'gdata3'=BILG
'gdata4'=LILG
'gdata5'=VLIBG
'gdata6'=VIPK
'gdata7'=VIYPK
'gdata8'=LIRP
'gdata9'=LIV;

style GraphDataText from GraphDataText /
fontsize = 9pt;
end;
quit;
[/pre]
SAS Employee
Posts: 963

Re: sgplot datalabel font-size

And, for the sake of those that might be wondering how to do this with traditional "proc gplot" ...


symbol1 value=dot interpol=none pointlabel=("#name" height=1.5pct);

proc gplot data=sashelp.class;
plot height*age=1;
run;
N/A
Posts: 1

Re: sgplot datalabel font-size

Hi,
I tried this solution for a similar problem but it dosn't work for me.
I would like to increase the resolution of my graph-output. Therefor, I increased width and hight in the ods graphics statement. Unfortunately the font size stayed at the same size.

It would be nice, if someone could help my finding a way to get a bigger font size!

Thanks in advance!

Gunter

Here is my code:

/*Plots der Verteilungen*/
proc template;
define style styles.bigtext;
parent=styles.listing;
style GraphValueText from GraphValueText /
fontsize=20pt
;
end;
run;
ods html gpath='H:\SAS\zw\bilder' style=bigtext ;
ods graphics / reset=all width=1100px height=300px border=off style=bigtext;

proc template;
define statgraph sgscatter_gunter2;

begingraph / includeMissingDiscrete=true;
EntryTitle "" /;
layout lattice / pad=(top=3) rowgutter=10 columngutter=10 columns=4 columnDataRange=data rowDataRange=union columndatarange=union ;
ColumnAxes;
ColumnAxis / displaysecondary=none griddisplay=off offsetmin=0.05 offsetmax=0.05 linearopts=(viewmin=0 viewmax=20);
ColumnAxis / displaysecondary=none griddisplay=off offsetmin=0.05 offsetmax=0.05 linearopts=(viewmin=0 viewmax=10);
ColumnAxis / displaysecondary=none griddisplay=off offsetmin=0.05 offsetmax=0.05 linearopts=(viewmin=0 viewmax=10);
ColumnAxis / displaysecondary=none griddisplay=off offsetmin=0.05 offsetmax=0.05 linearopts=(viewmin=0 viewmax=140);
EndColumnAxes;

RowAxes;
EndRowAxes;
histogram diag2 /xvalues=midpoints binwidth=2 fillattrs=(color=lightgrey) ;
histogram anz2 / xvalues=midpoints binwidth=1 fillattrs=(color=lightgrey);
histogram xanz2 /xvalues=midpoints binwidth=1 fillattrs=(color=lightgrey);
histogram klasse2 /xvalues=midpoints binwidth=7 fillattrs=(color=lightgrey);
endlayout;
endgraph;
end;
run;
proc sgrender data=lak1_geneuto3
template=sgscatter_gunter2;
label anz2='ANZ' klasse2='DS' diag2='DIAG' xanz2='ANZ14';

run;
SAS Super FREQ
Posts: 864

Re: sgplot datalabel font-size

Hey Gunter,

If the goal is to increase the graph resolution, use the IMAGE_DPI option on the ODS destination statement (for PRINTER or PDF, use the DPI option). If you are trying to do this with HTML output, I have found that browsers do not typically handle images higher than 100dpi very well. Let me know if this works out for you.

Thanks!
Dan
Post a Question
Discussion Stats
  • 6 replies
  • 5946 views
  • 0 likes
  • 4 in conversation