Dear SAS community,
i want to unbold the title of a SGPANEL graphic but i haven't found a working solution for it. here is my code:
data Gesamt_Pflanzen_TM_NStufe_MT1;
...
/* Presettings */
ods html5 style=analysis path="D:\Masterthesis\Statistik\2024\Grafiken"
file="Gesamt-Pflanzen-TM_25-4-24_NStufe.html";
ods graphics / reset;
ods graphics / width=3.5in height=3.0in;
ods escapechar='^';
* ods text="^S={font_face='Arial' font_weight=normal font_size=11pt color=black}Mischungsverhältnis Erbse : Gerste (%)"; /* hasn't worked */
title height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
/* Data preparation */
data Gesamt_Pflanzen_TM_NStufe_MT1;
set Gesamt_Pflanzen_TM_NStufe_MT1;
Low = Mittelwert - Standardfehler; /* Untere Grenze Fehlerbalken*/
High = Mittelwert + Standardfehler; /* Obere Grenze Fehlerbalken */
LabelPos = High + 10.0; /* Position der Buchstaben */
run;
proc format;
value NStufeFmt
0 = "0 kg N ha(*ESC*){unicode '207B'x}^{unicode '00B9'x}"
1 = "96 kg N ha(*ESC*){unicode '207B'x}^{unicode '00B9'x}";
run;
proc format;
value BehandlungFmt
1 = "0:100"
2 = "100:0"
3 = "90:10"
4 = "70:30"
5 = "80:40"
6 = "80:30"
7 = "50:50"
8 = "Brache";
run;
/* Creating bar chart*/
proc sgpanel data=Gesamt_Pflanzen_TM_NStufe_MT1 noautolegend/* Legende wird nicht automatisch erstellt */;
format Behandlung Behandlungfmt.;
panelby Behandlung / noheaderborder headerattrs=(size=11pt weight=normal)
columns=5 rows=1 novarname;
format Duengerstufe NStufefmt.;
vbarparm category=Duengerstufe response=Mittelwert /
group=Duengerstufe
groupdisplay=cluster;
highlow x=Duengerstufe low=Low high=High / group=Duengerstufe
lineattrs=(color=black thickness=1 pattern=solid) /* Schwarze, durchgezogene Linie */
highcap=serif lowcap=serif; /* vertikale Striche an den Enden */
scatter x=Duengerstufe y=LabelPos /
datalabel=Buchstabe /* Buchstaben für Fehlerbalken */
datalabelattrs=(size=10pt weight=bold color=black)
datalabelpos=center /* Zentrierung der Buchstaben auf Fehlerbalken */
markerattrs=(size=0); /* Unsichtbarer Marker */
rowaxis label="Pflanzen-TM (kg ha^{unicode '207B'x}^{unicode '00B9'x})" labelattrs=(size=11pt);
colaxis label="Düngerstufe" labelattrs=(size=11pt weight=normal) valueattrs=(size=10pt)/* Schriftgröße der Achsenwerte */;
run;
ods html5 close;title font='Arial' " " height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
EDIT:
This is the result with my fake-data:
Fake data:
data Gesamt_Pflanzen_TM_NStufe_MT1;
do Behandlung = 1 to 8;
Duengerstufe = mod(Behandlung,2);
do Mittelwert = 100 to 1000 by 100;
Standardfehler=0.1*Mittelwert;
Buchstabe=Mittelwert;
output;
end;
end;
run;
Remember always provide test data! It wasn't that hard to generate some... right?
Bart
title font='Arial' " " height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
EDIT:
This is the result with my fake-data:
Fake data:
data Gesamt_Pflanzen_TM_NStufe_MT1;
do Behandlung = 1 to 8;
Duengerstufe = mod(Behandlung,2);
do Mittelwert = 100 to 1000 by 100;
Standardfehler=0.1*Mittelwert;
Buchstabe=Mittelwert;
output;
end;
end;
run;
Remember always provide test data! It wasn't that hard to generate some... right?
Bart
It works. Thank you really much!
I'm sorry, i haven't thought of sample data.
That was a really creative solution, @yabwon! For the record, the title boldness is coming from the "Analysis" style definition. If you use this style a lot, you might want to derive a new Analysis (let's call it "my_analysis") that removes the bold titles. You will only need to run this code once, as it will store the style in your SASUSER by default.
proc template;
define style my_analysis;
parent=styles.analysis;
class GraphFonts /
"GraphAnnoFont" = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphTitle1Font' = ("<sans-serif>, <MTsans-serif>",14pt)
'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>",11pt)
'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt,italic)
'GraphLabelFont' = ("<sans-serif>, <MTsans-serif>",10pt,bold)
'GraphLabel2Font' = ("<sans-serif>, <MTsans-serif>",10pt)
'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",9pt)
"GraphUnicodeFont" = ("<MTsans-serif-unicode>", 9pt)
'GraphDataFont' = ("<sans-serif>, <MTsans-serif>",7pt);
end;
run;
Hi Paige.
To be 100% honest, I'm not sure how it worked.
The first track that it (font=) could help was this part of the documentation:
So I've started with simple:
title font='Arial' height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
which didn't work:
Then using good old "by try&error" approach I added:
title font='Arial' "ABC" height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
Which gave:
And then by replacing ABC with space the final version popped up.
But... I did some more experiments after you asked about explanation and here what I'v got:
When I add "/bold" to the font name it "does not work" again:
title font='Arial/bold' " " height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
Result:
What's even more interesting adding, adding "/italic" (only) makes it BOTH italic and bold:
title font='Arial/italic' " " height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
But when you make it like this:
title font='Arial/italic' " " height=11pt font='Arial' "Mischungsverhältnis Erbse : Gerste (%)";
works again (!)...
Another "interesting" behaviour, when I play with multiple different fonts, e.g.,
title font='Arial' " " font='Times New Roman' "Mischungsverhältnis Erbse : Gerste (%)";
the "Gesamt-Pflanzen-TM_25-4-24_NStufe.html" file has Arial in it, but the "default" SAS html document generated in WORK's sashtml1.htm file is Times...
(even if there is no Arial at all...
title font='Times New Roman' " " height=11pt "Mischungsverhältnis Erbse : Gerste (%)";
it displays Arial)
All the best
Bart
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.