我有一个来自100个用户的调查,我正在尝试计算一些统计数据。我的调查中的相关字段如下所示:
Gender Interests
B1: Male D1: Running, Snowboarding, Mountain Bikes
B2: Male D2: Programming, Running, Paintball
B3: Female D3: Bowling, Gymnastics
B4: Male D4: Rock Climbing, Running,
我需要计算对“跑步”感兴趣的男性百分比。文本将始终在字符串中显示为“正在运行”,但它可能以不同的顺序出现。
这是我到目前为止所做的:
=SUM(
COUNTIF(
D1:D100,ISNUMBER(
SEARCH(D1:D100,"Running")
)
)
)
注意我尚未考虑男性/女性标准。该表达式当前返回0。
非常感谢任何帮助。
答案 0 :(得分:2)
一种简单的方法就是稍微分解你的计算。
在另一栏中使用如下公式:
=IF(AND(B1="Male",ISNUMBER(SEARCH("Running",D1))),1,0)
这将为每个男性所有人提供1,并且将“Running”列为兴趣,将0列为所有其他人。将其一直复制到工作表中,然后很容易计算百分比,例如,如果列是E:
=SUM(E1:E100)/100
答案 1 :(得分:1)
你还应该测试一下这个比例(喜欢跑步的男性比例)是否是侥幸。
您可以进行(Pearson或似然比)卡方检验以确定比例是否与预期不同。
你也可以做Fisher's Exact Test,看看,例如,性别之间的比例是否不同。
答案 2 :(得分:0)
您可以使用Excel和ADO做很多事情。
Dim cn As Object
Dim rs As Object
Dim sFile As String
Dim sCn As String
Dim sSQL As String
Dim s As String, f As String
Dim sa As Variant
Dim i As Integer, c As Integer
Dim r As Range
''This is not the best way to refer to the workbook
''you want, but it is very conveient for notes
''It is probably best to use the name of the workbook.
sFile = ActiveWorkbook.FullName
sCn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFile _
& ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open sCn
sSQL = "SELECT interests " _
& "FROM [Sheet1$] "
rs.Open sSQL, cn, 3, 3
With Worksheets("Sheet2")
s = rs.GetString(, , , ",")
sa = Split(s, ",")
c = 1
For i = 0 To UBound(sa)
Set r = .Range("a1:a" & c)
f = Trim(sa(i))
If r.Find(f) Is Nothing Then
c = c + 1
.Cells(c, 1) = f
End If
Next
.Cells(1, 1) = "Interests"
.Cells(1, 2) = "Male"
.Cells(1, 3) = "Female"
For i = 2 To c
rs.Close
sSQL = "SELECT Gender, Count(Gender) As GNo " _
& "FROM [Sheet1$] " _
& "WHERE Interests Like '%" & .Cells(i, 1) & "%' " _
& "GROUP BY Gender"
rs.Open sSQL, cn
Do While Not rs.EOF
If rs.Fields("Gender") = "Male" Then
.Cells(i, 2) = rs.Fields("GNo")
ElseIf rs.Fields("Gender") = "Female" Then
.Cells(i, 3) = rs.Fields("GNo")
End If
rs.MoveNext
Loop
Next
End With
''Tidy up
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub