Can I use unpaired t-test to test the difference between the means of two categories extracted from different questionnaires? I have 40 questionnaires, each one consists of one question comparing two variables A and B. A and B in these 40 questionnaires are different forms of two categories X and Y.
      X       Y
Q1   41      24
Q2   30      15
...
Q40  33      17

Each questionnaire was answered by different numbers of subjects. So, since the numbers of subject in each questionnaire vary, I changed the data to the proportions of subjects who either chose A or B:
      X       Y
Q1   .63     .37
Q2   .67     .33
...
Q40  .66     .34

I want to know if there is a significant difference between X and Y in the whole questionnaires ($H_0: \mu_X=\mu_Y$, $H_a:\mu_X>\mu_Y$). Can I use the independent t-test to do that? If not, what do you suggest? Note that I want to compare the means of X and Y in the whole 40 questionnaires. All conditions to use the independent t-test (normality and equal variance) are satisfied.
 A: If I understand your experiment and your manipulation of data so far,
then in your second table you have two fractions for each questionnaire that add to 1.00 (as for Q2: 0.67 + 0.33 = 1.00).
In that case you may not treat the two columns X and Y (each with 60 fractions) as independent variables for a two sample t test (pooled or Welch). Once you know the proportion in X, the proportion in Y is
determined and so provides no additional information.
So it makes sense to focus just on the X column.
From the fragment shown, it seems that the X proportions tend to be
greater than the Y proportions, and the crux of your question is
whether X's do tend to be above 0.50. Now, let binomial random variable $G$ be the the number of X's (out of 60) that exceed 0.50.
Because I don't have the whole of the second table, I can't find $G$
for your experiment. But let me show results if $G = 45.$
In R, we use the exact binomial test binom.test as follows:
binom.test(45, 60, 1/2, alt="gr")

        Exact binomial test

data:  45 and 60
number of successes = 45, number of trials = 60, 
 p-value = 6.726e-05
alternative hypothesis: 
 true probability of success is greater than 0.5
95 percent confidence interval:
 0.6414602 1.0000000
sample estimates:
 probability of success 
                   0.75 

It turns out that any $G \ge 37$ is enough larger than 30
to give a P-value below $0.05 = 5\%,$ and hence a significantly
larger proportions in column X at the 5% level.
binom.test(37, 60, 1/2, alt="gr")$p.val
[1] 0.04623049

The figure below shows the binomial distribution of $G.$ One rejects the null hypothesis that X and Y
are equal against the alternative that X proportions are larger
for $G \ge 37.$

R code for figure:
x = 0:60;  PDF = dbinom(x, 60, .5)
hdr="PDF of BINOM(60,.5)"
plot(x, PDF, xlab="G", type="h", lwd=2, main=hdr)
 abline(h=0, col="green2")
 abline(v=36.5, lwd=2, lty="dotted", col="red")

