Help using Base SAS procedures

How to set label text size of axis in reg proc?

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

How to set label text size of axis in reg proc?

Hi, I am new in SAS 9.2. I want to modify label text size beside vertical axis and haxis? I am using code below but  it  does not create what I want.

title " ";

goptions hsize=6 vsize=4 ftext="arial" htext=2;  // htext does not change axis label text size

symbol color=red ci=blue width=2; 

  proc reg data=TEXT.CSVGUTE noprint; 

  var a b;  

  model a=b; 

  label a="city";  // city size  not changed

  label b="rate";  // rate size not changed, and numbers beside scales also not change. They look like smallest size.

   plot a*b; // But statistics information (statistics at the right margin  DOES change. It is  htext=2  

run;

And I do not want regression equation to be displayed on top of figure. I can use / nostat to suppress it at the margin. How to hide that equation?

Thanks a lot in advance.


Accepted Solutions
Solution
‎06-27-2012 02:32 PM
Valued Guide
Posts: 765

Re: How to set label text size of axis in reg proc?

hi ... you are correct, but you could always use GPLOT (and there's most likely a very nice looking answer using SGPLOT) ....

goptions reset=all hsize=6in vsize=4in ftext="calibri"

gunit=pct dev=png gsfname=gout;

symbol1 color=red v=dot ci=blue h=3 width=2;

filename gout 'z:\procreg.png';

title 'DATA PLOTED WITH PROC REG' ls=2;


proc reg data=sashelp.class noprint;

var weight height;

model weight = height;

label

weight = "WEIGHT (LBS)"

height = "HEIGHT (IN)"

;

* onde way to suppress the equation ... look at the LOG message;

plot weight*height / nostat modelht=1e6;

run;

quit;

* works with GPLOT;

goptions htext=4.5;

* match to PROC REG plot;

axis1 order=40 to 160 by 20 minor=none label=(a=90 "WEIGHT (LBS)");

axis2 order=50 to 72.5 by 2.5 minor=none offset=(1,1) label=("HEIGHT (IN)");

* add regression line;

symbol1 color=red v=dot ci=blue i=rl h=3 l=3 width=2;

filename gout 'z:\procgplot.png';

title h=6 'DATA PLOTTED WITH PROC GPLOT' ls=2;


proc gplot data=sashelp.class;

plot weight * height / vaxis=axis1 haxis=axis2;

run;

quit;


procreg.pngprocgplot.png

View solution in original post


All Replies
Solution
‎06-27-2012 02:32 PM
Valued Guide
Posts: 765

Re: How to set label text size of axis in reg proc?

hi ... you are correct, but you could always use GPLOT (and there's most likely a very nice looking answer using SGPLOT) ....

goptions reset=all hsize=6in vsize=4in ftext="calibri"

gunit=pct dev=png gsfname=gout;

symbol1 color=red v=dot ci=blue h=3 width=2;

filename gout 'z:\procreg.png';

title 'DATA PLOTED WITH PROC REG' ls=2;


proc reg data=sashelp.class noprint;

var weight height;

model weight = height;

label

weight = "WEIGHT (LBS)"

height = "HEIGHT (IN)"

;

* onde way to suppress the equation ... look at the LOG message;

plot weight*height / nostat modelht=1e6;

run;

quit;

* works with GPLOT;

goptions htext=4.5;

* match to PROC REG plot;

axis1 order=40 to 160 by 20 minor=none label=(a=90 "WEIGHT (LBS)");

axis2 order=50 to 72.5 by 2.5 minor=none offset=(1,1) label=("HEIGHT (IN)");

* add regression line;

symbol1 color=red v=dot ci=blue i=rl h=3 l=3 width=2;

filename gout 'z:\procgplot.png';

title h=6 'DATA PLOTTED WITH PROC GPLOT' ls=2;


proc gplot data=sashelp.class;

plot weight * height / vaxis=axis1 haxis=axis2;

run;

quit;


procreg.pngprocgplot.png
New Contributor
Posts: 4

Re: How to set label text size of axis in reg proc?

MikeZdeb, Thanks so much for your kind and generous help.  Your answer is nice. I found it suppress the equation and stat at the margin. The trick lies in second gplot proc. Thanks a million. The only imperfection is that the distance from vaxis label to vaxis is a little large if I do not use gunit=pct ( I use default).

Valued Guide
Posts: 765

Re: How to set label text size of axis in reg proc?

hi ... here's one way to move axis labels closer to the axes (it's a bit of "trial-and-error" specifying the X value for the Y-axis label and Y value for the X-axis label) ...

ps  looks as if you made your own comment the correct answer !!!

* make an annotate data set to add axis labels;

data anno;

xsys = '6'; ysys = '2'; x = 6; y = 100; angle = 90; text = "WEIGHT (LBS)";

output;

xsys = '2'; ysys = '6'; x = 61.25; y = 3; angle = 0; text = "HEIGHT (IN)";

output;

run;

* match to PROC REG plot ... specify blank labels to make room for annotate labels;

axis1 order=40 to 160 by 20 minor=none label=(a=90 " ");

axis2 order=50 to 72.5 by 2.5 minor=none offset=(1,1) label=(" ");

* add regression line;

symbol1 color=red v=dot ci=blue i=rl h=3 l=3 width=2;

filename gout 'z:\procgplot2.png';

title h=6 'DATA PLOTTED WITH PROC GPLOT' ls=2;

proc gplot data=sashelp.class annotate=anno;

plot weight * height / vaxis=axis1 haxis=axis2;

run;

quit;


procgplot2.png
New Contributor
Posts: 4

Re: How to set label text size of axis in reg proc?

MikeZdeb , Thanks so much again for your immediate reply. I am testing your code to modify the distance.

New Contributor
Posts: 4

Re: How to set label text size of axis in reg proc?

Thanks a lot,  Is it possible to move the whole data area (including haxis and vaxis ) closer to the vaxis label  rather than using annotate method. I was trying Origin=(), but failed.

Please look at gif. The distance from vaxis label  to vaxis is large. I mean to move vaxis and data area closer to "city output" without changing graphic size (hsize=6 vsize=4 ftext="arial" htext=2); Below is simplified code of your advice.

  goptions reset=all hsize=6 vsize=4 ftext="arial" htext=2;

  symbol1 color=red v=plus ci=blue i=rl l=1 width=5;

title '  ';

  axis1 label=('Mean city') minor=none;

  axis2 label=(angle=90 "Mean output") minor=none;

    proc gplot data=TEXT.CSVGUTE;

        plot  a*b / haxis=axis1 vaxis=axis2;

      

run;


Snap1.gif
Super User
Posts: 10,018

Re: How to set label text size of axis in reg proc?

Try to post it as GRAPH forum .

https://communities.sas.com/community/support-communities/sas_graph_and_ods_graphics

Or you can use Windows accessories - paint tool .  That is easy . OR PhotoShop - my favorite .

Ksharp

Valued Guide
Posts: 765

Re: How to set label text size of axis in reg proc?

hi ... sorry for the delay here

here's a question ... is the y-variable formatted?

if you look the attached, the y-axis label is much further away from the y-axis values in GPLOT10 than in GPLOT3 and the only difference was the format used for the y-axis variable ...

proc gplot data=sashelp.class;

plot weight * height / vaxis=axis1 haxis=axis2;

format weight 10.;

run;

quit;


gplot10.pnggplot3.png
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 1321 views
  • 3 likes
  • 3 in conversation