Hi!
I used XAXISTABLE in PROC SGPLOT to show text values. For variable "Charge" the values overlap.
Is it possible to split the values automatically if the space is to small? I couldn't find the solution with VALUEATTRS or FITPOLICY=split.
xaxistable Charge Beschichtung Konjugat / location=inside;
Best regards
Antje
@AntjeWestphal wrote:
To insert the line break after a fixed number of characters sounds good because it's important to see if there is a change in the curves after changing the lot. But can you give me a hint where to insert the floor(length(charge)/2) please?
In data PF4_2; set PF4_2; format Charge2 $21.; Charge2=floor(length(Charge)/2); run; the results are numbers.
With floor(length(Charge)/2) the line break would not be inserted after a fixed number of characters, but in the middle of the string, more precisely: after 3 characters for strings of lengths 6 or 7, after 4 for lengths 8 and 9, etc. Do you have lot numbers of length 21, as your FORMAT statement suggests? In this case one split might not be enough.
/* Example data */
data have;
input Charge $21.;
cards;
WKF2016
017/17I
sehr_lange_Chargennr.
;
/* Split CHARGE values in the middle */
data want(drop=s);
set have;
length Charge2 $23; /* (max. length of CHARGE)+2 */
s=floor(length(charge)/2);
charge2=substr(charge,1,s)||'0D0A'x||substr(charge,s+1);
run;
(Note that the line breaks do not occur in PROC PRINT output.)
Welcome to the SAS community 🙂
Can you show us your entire code? What version of SAS do you use?
Thank you!
SAS-Version: 9.4
ods graphics on / width=25cm height=15cm;
options nodate nonumber orientation=landscape topmargin="2.5cm" center;
ods html close;
ods pdf file='Z:\Antje\tempSAS\PF4 QK_07.2018.pdf';
ods layout start; ods region x=0cm y=0cm;
PROC SGPLOT DATA = PF4_2;
styleattrs datacontrastcolors=(blue red green magenta yellow black) WALLCOLOR=LTGRAY
datasymbols=(x);
SERIES X = Datum2 Y = MW_IgG_posKontr / markers lineattrs=(pattern=solid);
SERIES X = Datum2 Y = MW_IgG_negKontr / markers lineattrs=(pattern=solid);
SERIES X = Datum2 Y = MW_IgG_posKontr12verd / markers lineattrs=(pattern=solid);
SERIES X = Datum2 Y = MW_IgG_posKontr14verd / markers lineattrs=(pattern=solid);
SERIES X = Datum2 Y = MW_IgG_posKontr18verd / markers lineattrs=(pattern=solid);
xaxistable Charge Beschichtung2 Konjugat / location=inside;
keylegend/position=bottom valueattrs=(family=arial) down=10;
TITLE height=12pt font='arial' 'PF4-Kontrollen IgG Juli 2018';
xaxis label='Juli' labelattrs=(family=arial size=12pt)
valueattrs=(family=arial size=12pt);
yaxis grid gridattrs=(color=black) values=(0 to 3 by 0.5) label='Extinktion' labelattrs=(family=arial size=12pt) valueattrs=(family=arial size=12pt );
where Monat='07/2018'; run;
ods layout end;
ods pdf close;
ods html;
You could make graph wider by
ods graphics /width=2000px ..............;
or change FONTSIZE be smaller ?
The graph is already as wide as possible and the font size is really small. ![]()
Unbelievable '0D0A'x could change line .
data have;
set sashelp.class;
new_name=catx(' ',name,'0D0A'x,'xxxx');
run;
ods escapechar='~';
proc sgplot data=have(where=(sex='F'));
SERIES X = weight Y = height/ markers lineattrs=(pattern=solid);
xaxistable new_name / labelattrs=(size=40) location=outside valueattrs=(size=10) ;
run;
Another option: Use modified Charge values.
Example:
Charge='WKF'||'0D0A'x||'2015';
Result:
The values of Charge (= lot number) change over time:
@AntjeWestphal wrote:
The values of Charge (= lot number) change over time:
As long as there are only a few different patterns (e.g. WKFyyyy and nnn/nnx and perhaps a few more), it should be possible to insert the line break ('0D0A'x) programmatically at a suitable position. In any case one could insert it after a fixed number of characters or, e.g., after floor(length(charge)/2) characters, but I would like to avoid breaks such as WKF2-016.
To insert the line break after a fixed number of characters sounds good because it's important to see if there is a change in the curves after changing the lot. But can you give me a hint where to insert the floor(length(charge)/2) please? ![]()
In data PF4_2; set PF4_2; format Charge2 $21.; Charge2=floor(length(Charge)/2); run; the results are numbers.
@AntjeWestphal wrote:
To insert the line break after a fixed number of characters sounds good because it's important to see if there is a change in the curves after changing the lot. But can you give me a hint where to insert the floor(length(charge)/2) please?
In data PF4_2; set PF4_2; format Charge2 $21.; Charge2=floor(length(Charge)/2); run; the results are numbers.
With floor(length(Charge)/2) the line break would not be inserted after a fixed number of characters, but in the middle of the string, more precisely: after 3 characters for strings of lengths 6 or 7, after 4 for lengths 8 and 9, etc. Do you have lot numbers of length 21, as your FORMAT statement suggests? In this case one split might not be enough.
/* Example data */
data have;
input Charge $21.;
cards;
WKF2016
017/17I
sehr_lange_Chargennr.
;
/* Split CHARGE values in the middle */
data want(drop=s);
set have;
length Charge2 $23; /* (max. length of CHARGE)+2 */
s=floor(length(charge)/2);
charge2=substr(charge,1,s)||'0D0A'x||substr(charge,s+1);
run;
(Note that the line breaks do not occur in PROC PRINT output.)
Thank you Reinhard, that works! ![]()
I hoped to get an option within the SGPLOT but that's really fine!
If they are of few values then check class= for xaxistable
ods graphics / reset=all;
ods graphics / width=4.5in;
proc sgplot data=sashelp.class (where=(age < 13));
scatter x=name y=height;
xaxistable age / class=age title="Student Age" location=inside
valueattrs=(color=red)
labelattrs=(color=red)
titleattrs=(color=red) ;
xaxistable weight height / valueattrs=(color=blue);
run;
Thanks for that idea, but it doesn't work on my graph.
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.