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

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:

gabonzo_0-1637168055413.png

 

gabonzo_1-1637168076076.png

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Change your statement from CLASS to BY which is the equivalent of running PROC UNIVARIATE multiple times with each group individually.

View solution in original post

3 REPLIES 3
Reeza
Super User

Change your statement from CLASS to BY which is the equivalent of running PROC UNIVARIATE multiple times with each group individually.

gabonzo
Quartz | Level 8
Thank you, that works. However, it generates several plots instead of generating panels.
cyrus
SAS Employee

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 336 views
  • 5 likes
  • 3 in conversation