BookmarkSubscribeRSS Feed
SASuserlot
Barite | Level 11

I am  trying create the KM plot, my Y axis lable is very long,  How can I split and fit in to the lable in the graph also want to make it bold. This is the code   I am using for Plot options

goptions reset   = (global all) 
         device  = sasemf
         ftext   = "courier new unicode ms/unicode"
         ftitle  = "courier new unicode ms/unicode"
         xmax    = 9.0in 
         ymax    = 3.8in
         gunit   = pt;

axis1 value = (h=10pt rotate=0 angle=0)
      order = (0 to 225 by 25)
      label = (f = "courier new unicode ms/unicode" h=8pt j=c "contious days of requiremnt" j=c" " j=c" ")
      major = (h=1pt w=1)
      minor = (n=4)
;

axis2 value  = (h=10pt)
      order  = (0 to 1 by 0.1)  
      offset = (.1in)
      label  = (f = "courier new unicode ms/unicode" h=8pt a=90 /*j=c " " j=c " "*/ j=c "This is very long label I want to split and arrange horizontal")
      major  = (h=1pt w=1)
      minor  = (n=4)
;

legend1 shape    = symbol(40,6)
        mode     = reserve 
        position = (bottom center outside) 
        value    = (h=8.5)
        label    = (h=9 " " position=left j=l) 
        space    = 1
        across   = 1
        down     = 1
;

/*symbol1 i=steplj c=black  w=2 h=2 l=1;*/
symbol2 i=steplj c=black    w=2 h=2 l=1;

the output on Y axis is like below in graph.

SASuserlot_1-1635958253129.png

Sas Log giving the warning about the enough space;


WARNING: Not enough space for the label "Failure". Variable name is used.

NOTE: There were 78 observations read from the data set WORK.lg.
NOTE: There were 59 observations read from the data set WORK.lg.
NOTE: PROCEDURE GPLOT used (Total process time):
real time 0.12 seconds
cpu time 0.06 seconds

 

thanks in advance.

 

9 REPLIES 9
Reeza
Super User
Don't use SAS/GRAPH, use SGPLOT and the XAXIS/YAXIS statements instead. Better quality graphics for starters for sure and more control.
https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...

Within SGPLOT here are two methods to split an axis label. I think the Annotate option will work is SAS/GRAPH if you need to stick with that for some reason.
https://stats.idre.ucla.edu/sas/code/generating-multiline-axis-labels-in-sas-proc-sgplot/
SASuserlot
Barite | Level 11

Thank you for the response. Its adhoc work , so I was sticking to the existed code of using annote . I tried the link but I am not able to get the ans. can you please provide an example if possible. Thanks

Reeza
Super User
Please show what you tried and happy to help you fix/adjust it as necessary.
I'm assuming you'll be using the second link with the option titled
"Using an annotation dataset for complete control of axis label placement"
RAVI2000
Lapis Lazuli | Level 10

In the axis2 for order value make it (0 to 0.5(uptill where you want the value to display) by 0.1). This should help you.

SASuserlot
Barite | Level 11

That just reduced the y axis length to 0.5 instead of 1 ( which is bigger the length than 0.5 option). I tried to increase by 0.05 but that did not help.

RAVI2000
Lapis Lazuli | Level 10
My bad I thought it was for axis. Just confirmed you asked for label.
ballardw
Super User

Is this what you are looking for? The Split= option uses the specified character to split the text.

      label  = (f = "courier new unicode ms/unicode" h=8pt a=90 j=c 
       split='/'
       "This is very long /label I want to split /and arrange horizontal")
SASuserlot
Barite | Level 11
It worked Thank you. Can you also what option need to use for making font bold?
ballardw
Super User

With the older SAS Graph Axis statement fonts are sometimes a bit tricky. If a font has a BOLD version it may be addressed by adding the Bold option in the Font settings

 

Possibly:

 label  = (f = "courier new unicode ms/unicode bold" h=8pt a=90 j=c 
       split='/'
       "This is very long /label I want to split /and arrange horizontal")

 or possibly

 label  = (f = "courier new unicode ms/unicode/bold" h=8pt a=90 j=c 
       split='/'
       "This is very long /label I want to split /and arrange horizontal")

 Unicode is way newer than my experience with SAS/Graph and the various statements like Axis so I am not sure how well it fits in with the old syntax. Some fonts had specific font names like "Arial Bold" (not sure it that was legit but the font name was required to use the bold versions of some.

 

I also seem to recall dealing with some issues about font families versus actual font names that cropped up.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1421 views
  • 5 likes
  • 4 in conversation