BookmarkSubscribeRSS Feed
curlyelsie
Calcite | Level 5

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!

6 REPLIES 6
ballardw
Super User

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

2: Look up SG annotation data sets

Jay54
Meteorite | Level 14

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.

curlyelsie
Calcite | Level 5

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;

DanH_sas
SAS Super FREQ

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;

Jay54
Meteorite | Level 14

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.

ballardw
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 6 replies
  • 3391 views
  • 3 likes
  • 4 in conversation