Hi,
I have a dataset where my variable of interest is adv_turnout and I have four treatment levels: "AP", "OP", "Both" and "None".
I want to produce Q-Q plots for all the four treatments, so I use the following code:
proc univariate data=anova_input normal cipctldf;
class missing_info;
var adv_turnout;
qqplot / normal (mu=est sigma=est);
run;
Note that I want to compare the qqplots with a normal distribution, with parameters estimated from the data.
The issue I have is that, for all four plots, the same mu and sigma are used: that is, the mu and sigma estimated from the first group "AP". See the following plots:
Is this a bug?
Is there a way to match the qqplots with the correct mu and sigma estimations? I could run PROC UNIVARIATE four times separately for each subset, but that seems cumbersome.
Thanks.
Change your statement from CLASS to BY which is the equivalent of running PROC UNIVARIATE multiple times with each group individually.
Change your statement from CLASS to BY which is the equivalent of running PROC UNIVARIATE multiple times with each group individually.
To get them in the same plot, you can use PROC SGPANEL. For example:
proc sort data=sashelp.class out=class; by sex;
run;
ods exclude qqplot;
ods output qqplot=qqdata;
proc univariate data=class;
by sex;
var height;
qqplot / normal(mu=est sigma=est);
run;
data qqdata;
set qqdata;
label = "Mu=" || put(RefInt,best6.) ||", Sigma=" || put(RefSlope,best6.);
run;
proc sgpanel data=qqdata;
panelby sex / columns=1;
lineparm x=0 y=refInt slope=refSlope;
scatter x=quantile y=data;
inset label / position=BottomRight;
run;
PROC UNIVARIATE uses the same reference line for each plot to ensure they can share a common x-axis.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.