Data visualization with SAS programming

Help with SGSCATTER - Changing Axes & Overlaying Polygons

Reply
New Contributor
Posts: 2

Help with SGSCATTER - Changing Axes & Overlaying Polygons

I've reviewed the SAS help for SGSCATTER and cannot find information on the following;

1) How to adjust the axes on the plot.  I have two plots that I would like to have the same ranges for the X and Y axes. 

2) Overlaying colored polygons.  I'd like to shade different "zones" in my scatter plot.  Perhaps SGSCATTER isn't the best procedure for this - if not, I'm open to other suggestions.

Thanks!

Grand Advisor
Posts: 10,239

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

1: Uniscale=All  as an option on the PLOT statement.

2: Look up SG annotation data sets

SAS Super FREQ
Posts: 1,081

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

It will help if you can provide more information. 

  1.  What release of SAS are you using? 

  2.  Are you using SGSCATTER ot create a panel of comparative scatter plots, or just graphs with scatter plots.

  3.  Polygon plot (SAS 9.4M1) is not supported in SGSCATTER.  You likely need to use SGAnnotate.

  4.  It would help if you attach your working code with some data.

New Contributor
Posts: 2

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

Thanks!

1) I'm using SAS 9.4 for Windows.

2) I'm only using it to create graphs with scatter plots (not trying to put together more than one plot in a panel)

3) Thanks!  I haven't used SGAnnotate before, but I'll look into it.

Below is an edited version of code I've used.  I have already used uniscale=all, but this doesn't do what I'd like.  I'd like to create two separate scatter plots (not a side-by-side comparison in a panel, but imagine a scatter plot created using the dataset "one" below and a second created using another dataset "two")--I'd like these plots to have the same ranges for the x and y axes.

data one;

  input TYPE $ Xvalue Yvalue;

  datalines;

  A  0 3.2

  B  1.6 18.6

  C  15.1 1.9

  D  0 7.7

  E  37.3 2.1

  F  29.4 78

  G  60.3 15.4

  H  19.4 6.2

  I  0 5.6

  J  2.4 1.3

  K  0 54

  L  15.9 48.5

  M  3.2 0

  ;

  run;

  ods html style = journal;

  ods graphics / width = 6in height = 6in;

  proc sgscatter data = one;

       plot Yvalue*Xvalue /  group = TYPE

                                     datalabel = TYPE

                                     nolegend

                                     uniscale = ALL;

  run;

SAS Super FREQ
Posts: 890

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

For this type of plot, you probably should not be using SGSCATTER. You should be using SGPLOT. SGSCATTER is designed to create panels of scatter plots, which is why you found the number of axis options limiting. SGPLOT will give you much more control for the "single-cell" plot you're creating. For example:

proc sgplot data = one noautolegend;

       xaxis min=<min value> max=<max value>;

       yaxis min=<min value> max=<max value>;

       scatter y=Yvalue x=Xvalue /  group = TYPE

                                    datalabel = TYPE;

  run;

SAS Super FREQ
Posts: 1,081

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

I was going to suggest the same, hence my questions.  Additionally, if you want SGPLOT to make the axes uniform across both graphs, you could combine the data of "One" and "Two" in to one data set with a "BY" value, and then use the BY statement to output two separate graphs with uniform  axes using the UNIFORM=SCALE option.

Also, with SGPLOT, you can use the POLYGON statement (SAS 9.4M1) to draw polygons instead of annotate.

Grand Advisor
Posts: 10,239

Re: Help with SGSCATTER - Changing Axes & Overlaying Polygons

You might want to change to sgplot as the xaxis and yaxis statements give you more control over axis contents.

Ask a Question
Discussion stats
  • 6 replies
  • 610 views
  • 3 likes
  • 4 in conversation