Hi there, I have a data with two treatments (treated and control group).
I have behavioral class (Adequate, Calm, Very calm, Restless and Very restless) and its percentage in each group .
I did the proc freq and would like to compare the percentage frequency between group in each score.
My table is like this:
Class | Score | Treatment | Treatment | P-value |
TREATED (%) | CONTROL (%) | |||
Adequate | 16.9 to 21.2 | 0.00 | 11.11 | |
Restless | 21.3 to 25.6 | 0.00 | 6.35 | |
Calm | 12.5 to 16.8 | 5.56 | 9.52 | |
Very calm | ≤ 12.4 | 94.44 | 73.02 | |
Very restless | ≥ 25.7 | 0,00 | 0,00 |
I would like to calculate the P-value.
Is there a way to do that?
Thank you.
p-value implies a test. What test do you want to perform?
Hi Ballardw, thank you for helping me.
I would like to perform a t-test, thank you!
@aska_ujita wrote:
I would like to perform a t-test, thank you!
Hi @aska_ujita,
A two-sample t-test (see PROC TTEST documentation) compares the means of a continuous variable in two groups. So, not the percentages of the classified scores, but the original scores might be amenable to this test (especially if their distributions in the two treatment groups are approximately normal with similar variances). As a minimum for computing the test statistic you would need N (number of non-missing values), mean and standard deviation (or variance) per treatment group.
If only the classified scores are available, you can use a chi-square test or (in particular for small samples) Fisher's exact test for a comparison of the two frequency distributions (test of homogeneity). Both are available in PROC FREQ. I would not report p-values for comparisons of individual categories (unless these comparisons were pre-planned, with precautions for multiple testing). To assess the contribution of each category to the overall chi-square statistic, you can use the CELLCHI2 option of the TABLES statement, as shown in the code below:
/* Create sample data for demonstration */
data have;
do trt='treated','control';
do class=1 to 5;
input n @@;
output;
end;
end;
cards;
238 14 0 0 0
184 24 28 16 0
;
proc freq data=have;
weight n;
tables trt*class / chisq cellchi2 fisher;
run;
If you hypothesize a location shift in the distribution of scores in the treated vs. control group, a Wilcoxon rank-sum test would be a more specific approach. This test is available in PROC NPAR1WAY. Here's a code example for the above input dataset HAVE:
proc npar1way data=have wilcoxon plots=none;
class trt;
freq n;
var class;
run;
@aska_ujita wrote:
Hi Ballardw, thank you for helping me.
I would like to perform a t-test, thank you!
I think @ballardw wanted you to state exactly what hypothesis you want to test.
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.