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;
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
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.
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
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.