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

Hi,

 

 

I have data for 6 different groups and for each group I have the percentage of Males and Females in that group.

This is the data:

 

 

F

M

1

0.103967

0.896489

2

0.070575

0.929425

3

0.081081

0.918919

4

0.08221

0.91779

5

0.056566

0.945455

6

0.083333

0.916667

 

What I would like to know is wether there is a statisticlly significant diffenrece of the percenatge of malesa and females between the groups and how could SAS find that out. 

Thank you! 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Assuming you have frequencies, you would do:

 

data have;
input g nF nM;
datalines;
 1    76    655
 2    65    856
 3     3     34
 4    61    681
 5    28    467
 6     1     11
;

data long;
set have;
sex = "F"; freq = nF; output;
sex = "M"; freq = nM; output;
keep g sex freq;
run;

proc freq data=long;
tables g*sex / nopercent nocol;
exact fisher / mc;
weight freq;
run;
PG

View solution in original post

10 REPLIES 10
Reeza
Super User

You can look into the Chi square test - available under proc freq. 

There are also other tests available under Proc Freq that may be useful. Check the documentation. 

 

http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_freq_sec...

 

PGStats
Opal | Level 21

You need the frequencies (numbers of males and females) to test for differences between the proportions.

PG
Ksharp
Super User
Since there are only two levels, the simplest way is using proc ttest(parameter method for normal data),proc npar1way (non-parameter method).

data have;
input g F M;
cards;
1 0.103967 0.896489
2 0.070575 0.929425
3 0.081081 0.918919
4 0.08221 0.91779
5 0.056566 0.945455
6 0.083333 0.916667
;
run;
proc transpose data=have out=want name=Gender;
by g;
var f m;
run;
proc ttest data=want cochran ci=equal umpu;
class Gender;
var col1;
run;


/***************/
proc npar1way wilcoxon correct=no data=want;
class Gender;
var col1;
exact wilcoxon;
run;




Two ways show the significant . there is difference between F and M .


Method	Variances	DF	t Value	Pr > |t|
Pooled	Equal	10	-91.57	<.0001
Satterthwaite	Unequal	9.9914	-91.57	<.0001
Cochran	Unequal	5	-91.57	<.0001

Kruskal-Wallis Test
Chi-Square	8.3077
DF	1
Pr > Chi-Square	0.0039




Reeza
Super User

I don't think that's statistically valid - it's a categorical variable, ttest is for continuous variables. 

 


@Ksharp wrote:
Since there are only two levels, the simplest way is using proc ttest(parameter method for normal data),proc npar1way (non-parameter method).
data have;
input g F M;
cards;
1 0.103967 0.896489
2 0.070575 0.929425
3 0.081081 0.918919
4 0.08221 0.91779
5 0.056566 0.945455
6 0.083333 0.916667
;
run;
proc transpose data=have out=want name=Gender;
by g;
var f m;
run;
proc ttest data=want cochran ci=equal umpu;
class Gender;
var col1;
run;


/***************/
proc npar1way wilcoxon correct=no data=want;
class Gender;
var col1;
exact wilcoxon;
run;




Two ways show the significant . there is difference between F and M .


Method	Variances	DF	t Value	Pr > |t|
Pooled	Equal	10	-91.57	<.0001
Satterthwaite	Unequal	9.9914	-91.57	<.0001
Cochran	Unequal	5	-91.57	<.0001

Kruskal-Wallis Test
Chi-Square	8.3077
DF	1
Pr > Chi-Square	0.0039





 

ilikesas
Barite | Level 11

Hi Xia,

 

actually in my data it is not 6 separate pairs of male and female but 6 different categories and each category has the given proportions of males and females. Unless I am mistaken (my knowledge of statistics is intermediate) the t test would test for the significance in the means of the 2 groups, therefore making a male mean of the 6 observations and a female mean of the 6 observations and comparing them. But what I would like to get is to know whether the real proportion of males and females is the same in all 6 categories, or if there are categories where the real proportions of makes and females are actually different.

 

Thanks!

Ksharp
Super User
Then follows what PG said. I think your data is too few and sparse, you can't said whether it is different between two cells(value).
ilikesas
Barite | Level 11

Hi Xia,

 

actually I have over 4000 observations with 2 variables: 1 for the category (1 to 6) and one for gender (0 and 1). I am looking into this "Chi square test", do you think its appropriate?

 

Thanks!

Reeza
Super User

Read up on it. You should be able to defend your decision to go with x method. 

 

https://en.m.wikipedia.org/wiki/Chi-squared_test

 

The chi-squared test is used to determine whether there is a significant difference between the expected frequencies and the observed frequencies in one or more categories. Does the number of individuals or objects that fall in each category differ significantly from the number you would expect? Is this difference between the expected and observed due to sampling variation, or is it a real difference?

 

 

 

What Statistical should I use?

http://www.ats.ucla.edu/stat/sas/whatstat/default.htm

Ksharp
Super User
Yeah. I think so. So your data actually is Contingency table ?
PGStats
Opal | Level 21

Assuming you have frequencies, you would do:

 

data have;
input g nF nM;
datalines;
 1    76    655
 2    65    856
 3     3     34
 4    61    681
 5    28    467
 6     1     11
;

data long;
set have;
sex = "F"; freq = nF; output;
sex = "M"; freq = nM; output;
keep g sex freq;
run;

proc freq data=long;
tables g*sex / nopercent nocol;
exact fisher / mc;
weight freq;
run;
PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 2907 views
  • 8 likes
  • 4 in conversation