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

I want to make two graphs via by-processing with the same scaling of X and Y axes. SGPLOT resolutely refuses to make uniform scaling of the X axes with UNIFORM=ALL, UNIFORM=SCALE and UNIFORM=XSCALE. The Y axes are made uniform, however.  Here's the code, and attached is the output. Sorry I can't easily include the dataset. In any case, it's probably something arcane to do with the attributes or something that I have got wrong. (BTW, I used log transformation and back-transformed, in case anyone picks up on the non-uniformity.) And can anyone see why I don't get red outlines on the markers?

 

Thank you!

 

 

title height=1.0 "&pred predicting &dep, Name means and between-Name quadratic";
ods graphics / reset width=16cm height=13cm imagemap attrpriority=none;
proc sgplot data=bothpred1 noborder noautolegend uniform=ALL;
reg x=Mean&pred.Unscaled y=PredM/degree=2 nomarkers lineattrs=(thickness=1 color=blue pattern=solid);
reg x=Mean&pred.Unscaled y=LowerM/degree=2 nomarkers lineattrs=(thickness=1 color=blue pattern=dot);
reg x=Mean&pred.Unscaled y=UpperM/degree=2 nomarkers lineattrs=(thickness=1 color=blue pattern=dot);
scatter x=Mean&pred.Unscaled y=Mean&dep/filledoutlinedmarkers
  markerattrs=(symbol=circlefilled size=10 color=red)
  markerfillattrs=(color=black);
yaxis label="Mean&dep" labelpos=top labelattrs=(size=10) valueattrs=(size=10);
by PosGrp;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

There is an issue in the proc, but I'm going to give you a simple fix. Add this line to your SGPLOT:

 

xaxis type=linear;

 

Let me know if that works for you.

 

Thanks!
Dan

View solution in original post

5 REPLIES 5
Rick_SAS
SAS Super FREQ

Two ways to accomplish what you want.

1. Use PROC SGPANEL. The PANELBY statement produces different plots for each level of a grouping variable, but you can use the UNISCALE= option to equate the ranges of the X axis, Y axis, or both.

2. Use PROC MEANS to get the min and max value of the data across all levels of the BY-group variable. Use those values in your current code as arguments to the MIN= and MAX= options on the XAXIS statement.

WillTheKiwi
Pyrite | Level 9
Thanks, Rick, but according to the documentation for SGPLOT, I should get uniform X axes:

ALL specifies that both the legend group values and the axis scaling are shared between all of the levels of the BY variable or variables.

I don't want to use a different plotting procedure, having spent hours-no, days, if you add it all up-getting just a rudimentary knowledge of how to get what I want out of SGPLOT.
DanH_sas
SAS Super FREQ

There is an issue in the proc, but I'm going to give you a simple fix. Add this line to your SGPLOT:

 

xaxis type=linear;

 

Let me know if that works for you.

 

Thanks!
Dan

GraphGuy
Meteorite | Level 14

You could use SAS/Graph Proc Gplot - its 'uniform' option keeps both the x and y axes uniform, across by groups.

Here's an example:

 

proc sort data=mapsgfk.uscity out=my_data;
by statecode;
run;

proc gplot data=my_data uniform;
by statecode;
plot lat*long;
run;

 

WillTheKiwi
Pyrite | Level 9
Thanks, Robert. As I said to Rick, I don't particularly want to switch plotting procedures, having put in a lot of time to get the code right for SGPLOT.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1705 views
  • 2 likes
  • 4 in conversation