BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Abdus-Salaam
Obsidian | Level 7

Dear SAS community,

 

i've created a bar chart with SGPANEL with five panels. My panel headings consist of two variables (Pflanzenart and Mischung). I've put these two variables in one variable (Behandlung) for the panel headings and the categories for the panels. I want now that one part of the heading (Pflanzenart) is in one line and the other part (Mischung) is in a new line below: I've tried it with:

Behandlung = catx('0A'x, put(Pflanzenart, PflanzenartFmt.), put(Mischung, MischungFmt.));

but both, Pflanzenart and Mischung are standing together in one line followed by an empty line.

 

Here is the complete code:

 

/* Voreinstellungen */
ods html5 style=analysis path="D:\Masterthesis\Statistik\2024\Grafiken"
          file="Pflanzen-TM_25-4-24_NStufe.html";
ods graphics /reset;
ods graphics / width=5in height=2.5in;
ods escapechar='^';

title height = 1.5 "Median der Pflanzen-Trockenmasse der Düngerstufen";
footnote "Düngerstufen innerhalb einer Behandlung mit gleichem Buchstabe sind nicht signifikant voneinander verschieden.";


/* Format für Duengerstufe*/
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;
/* Format für Pflanzenart */
proc format;
    value PflanzenartFmt
        1 = "Erbse"
        2 = "Gerste";
run;
/* Format für Mischung */
proc format;
    value MischungFmt
        0 = "RS"
        1 = "90:10"
        2 = "70:30"
        3 = "80:40"
        4 = "80:30"
        5 = "50:50";
run;

/* Datenvorbereitung */
data Pflanzen_TM_NStufe_MT1;
    set Pflanzen_TM_NStufe_MT1;
    Low = Median - Standardfehler; /* Untere Grenze Fehlerbalken*/
    High = Median + Standardfehler; /* Obere Grenze Fehlerbalken */
	LabelPos = High + 10.0; /* Position der Buchstaben */
	Behandlung = catx('0A'x, put(Pflanzenart, PflanzenartFmt.), put(Mischung, MischungFmt.));
run;


/* Erstellen des Balkendiagramms mit 2 Panels */
proc sgpanel data=Pflanzen_TM_NStufe_MT1;
    panelby Behandlung / noheaderborder headerattrs=(size=6pt weight=bold) novarname
		columns=8 rows=1;
	format Duengerstufe NStufefmt.;
    vbarparm category=Duengerstufe response=Median / 
		group=Duengerstufe
		groupdisplay=cluster;
    highlow x=Duengerstufe low=Low high=High / group=Behandlung 
		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 display=none; 
run;

ods html5 close;

 

Could you help me to get the contents of the variable Pflanzenart in the first line of the panel heading and the contents of the variable Mischung in the second line of the panel headings?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Instead of combining the two variables into one, just keep them separate and specify both of them on the PANELBY statement. Since you have NOHEADERBORDER enabled, it should give you that appearance of "splitting" the two values. Hope this helps!

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

Instead of combining the two variables into one, just keep them separate and specify both of them on the PANELBY statement. Since you have NOHEADERBORDER enabled, it should give you that appearance of "splitting" the two values. Hope this helps!

Abdus-Salaam
Obsidian | Level 7

Thank you really much, it worked 🙂

Ksharp
Super User

Here is DanH_sas 's way.

data have;
 set sashelp.heart(obs=200);
run;


proc sgpanel data=have;
panelby status sex / novarname noheaderborder headerbackcolor=white;
scatter x=weight y=height;
run;


Ksharp_0-1732954537196.png

 

 

Alternative way is using INSET statement.

proc sgpanel data=have;
panelby  status sex / noheader;
inset  status sex/position=top nolabel textattrs=(size=10);
scatter x=weight y=height;
rowaxis offsetmax=0.15;
run;

Ksharp_1-1732954609207.png

 

 

 

Abdus-Salaam
Obsidian | Level 7

Thank you for your explanation and the sample code. These were helpful 👍

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 320 views
  • 6 likes
  • 3 in conversation