BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
liangjz
Calcite | Level 5

proc sql;

create table myclass as

   select age,height,mean(height) as mHeight

   from sashelp.class

;

quit;

 

proc sgplot data=myclass;

  scatter x=age y=height;

  refline 14 /axis=x labelloc=inside  label="The Reference Line" lineattrs=(color=green);

run;

 

Is it possible to change the label “The reference Line” from horizontal to vertical?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Or add a data point or two and use a TEXT plot.

 

proc sql;
create table work.myclass as
   select age,height,mean(height) as mHeight
   from sashelp.class
;
quit;
data work.label;
   age=14.2;
   y=70;
   Labeltext= "The Reference Line";
run;
 
data work.plot;
   set work.myclass
       work.label;
run;
proc sgplot data=work.plot;
  scatter x=age y=height/ name='scatter';
  refline 14 /axis=x labelloc=inside  label="" lineattrs=(color=green);
  text x=age y=y text=labeltext /rotate=90 name='text';

  keylegend 'scatter';

run;

Changing the Rotate angle to =90 will make it read from top to bottom. Adjust the x and y coordinates to be "nice". There are also some text appearance options available with a Text plot, such as BACKLIGHT not available in REFLINE.

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

I can't find any option to rotate the label. SG-Annotation is the next best thing, but rather clumsy. You might also consider a compromise such as:

 

proc sgplot data=myclass;
  scatter x=age y=height;
  refline 14 /axis=x labelloc=inside  label="Reference/Line"  
  	lineattrs=(color=green) labelpos=min splitchar="/";
run;

after all, horizontal is always easier to read.

PG
liangjz
Calcite | Level 5

Hi PG,

 

Thanks for the info you posted -- agreed with you, with splitting label, it is nice. I don't have to use annotation.

 

Best,

 

John

ballardw
Super User

Or add a data point or two and use a TEXT plot.

 

proc sql;
create table work.myclass as
   select age,height,mean(height) as mHeight
   from sashelp.class
;
quit;
data work.label;
   age=14.2;
   y=70;
   Labeltext= "The Reference Line";
run;
 
data work.plot;
   set work.myclass
       work.label;
run;
proc sgplot data=work.plot;
  scatter x=age y=height/ name='scatter';
  refline 14 /axis=x labelloc=inside  label="" lineattrs=(color=green);
  text x=age y=y text=labeltext /rotate=90 name='text';

  keylegend 'scatter';

run;

Changing the Rotate angle to =90 will make it read from top to bottom. Adjust the x and y coordinates to be "nice". There are also some text appearance options available with a Text plot, such as BACKLIGHT not available in REFLINE.

liangjz
Calcite | Level 5

Thanks, ballardw. Text plot is much easier than annotation in this case for me at least. I really appreciate it.