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

Here is a dataset about abalone and its indexes. 

1)how can I calculate the percentage that the infant in the middle ring group by using sas procedure?

2)I have already got the percent of the infant (sex=I) abalones and the percent of the medium ring group(the ring values between 9 and 11, inclusive), but would I be able to conclude whether the ring group and the sex are associated of not based on these three percentages?  (actually the question(2) is not about the sas procedure, it is just a simple statistical question.)

 

THE INUT FORMAT HAS BEEN GIVEN:

 

DATA fn.abalone;
LENGTH GROUP $10;
INFILE 'C:\Users\Administrator\Desktop\SAS\final_takehome\abalone.txt' DLM=',' DSD;
/* change the path please! */
INPUT sex $ length diam height whole shucked viscera shell rings;

 
IF RINGS LT 9 THEN GROUP='SMALL';
ELSE IF RINGS GE 9 AND RINGS LE 11 THEN GROUP='MEDIUM';
ELSE IF RINGS GT 11 THEN GROUP='LARGE';

RUN;

 

 

 

 

thanks a lot!!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Contingency table tests are based on frequencies, not percentages. Compare:

 

DATA abalone;
LENGTH GROUP $10;
INFILE "&sasforum\datasets\abalone.txt" DSD;
INPUT sex $ length diam height whole shucked viscera shell rings;
IF RINGS LT 9 THEN GROUP='SMALL';
ELSE IF RINGS GE 9 AND RINGS LE 11 THEN GROUP='MEDIUM';
ELSE IF RINGS GT 11 THEN GROUP='LARGE';
RUN;

/* Tests based on frequencies */
proc freq data=abalone;
table sex*group / deviation chisq out=aba_pct;
exact fisher / mc;
run;

/* Check the percentages */
proc print data=aba_pct noobs; run;

/* Tests based on percentages */
proc freq data=aba_pct;
weight percent;
table sex*group / deviation chisq;
exact fisher / mc; /* Will not work because of non-integer frequencies */
run;
PG

View solution in original post

8 REPLIES 8
Phoebelee
Fluorite | Level 6

 

 

I think what my prof asked is just simply talking about whether would I be abel to conclude the association based on the three percentages and then use chi square test to check if the results match with the former guess.

Thanks!!

PGStats
Opal | Level 21

Contingency table tests are based on frequencies, not percentages. Compare:

 

DATA abalone;
LENGTH GROUP $10;
INFILE "&sasforum\datasets\abalone.txt" DSD;
INPUT sex $ length diam height whole shucked viscera shell rings;
IF RINGS LT 9 THEN GROUP='SMALL';
ELSE IF RINGS GE 9 AND RINGS LE 11 THEN GROUP='MEDIUM';
ELSE IF RINGS GT 11 THEN GROUP='LARGE';
RUN;

/* Tests based on frequencies */
proc freq data=abalone;
table sex*group / deviation chisq out=aba_pct;
exact fisher / mc;
run;

/* Check the percentages */
proc print data=aba_pct noobs; run;

/* Tests based on percentages */
proc freq data=aba_pct;
weight percent;
table sex*group / deviation chisq;
exact fisher / mc; /* Will not work because of non-integer frequencies */
run;
PG
PGStats
Opal | Level 21

Note: The relationship between rings and maturity is better illustrated with logistic regression:

 

data aba_maturity;
set abalone;
mature = sex in ("M", "F");
run;

proc logistic data=aba_maturity;
model mature(event="1") = rings;
effectplot fit(x=rings) / obs(jitter(y=0.1));
run;

FitPlot1.png

PG
Phoebelee
Fluorite | Level 6

Thank you, but would I be able to get an intuitive result just from those three percentages?

PGStats
Opal | Level 21

You cannot evaluate the relationship between two variables by looking at the proportions for only one variable. I would base my intuition on the deviations in the freq table. Percentages alone can be missleading as they can be based on small numbers. What if the total number of fish was only 20?

PG
Reeza
Super User

Always look at both the raw numbers and percentage. 

Raw to determine if it matters, percentage for comparison. If the percentages show a huge discrepancy it's usually because of the small N. 

 

What is the possibility of a hospital having only baby boys in a week? 

It depends on the number of events - if it only has one or two births a week, it's highly likely this could occur. If it has 1000 births it's really unlikely. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 8 replies
  • 1575 views
  • 1 like
  • 3 in conversation