Hi everyone,
I have a dataset with a bunch of cases (rows) and variables (columns) and I want to do various conditional counts of the cases but there is also a variable WEIGHT that I need to use to weight each case when I do the count. But I have no idea how to do a regular conditional count, let alone how to do one that takes into account the weight variable.
What I would like to do is this. I want to know the number of rows that have such and such a value but weight each case in the count by the value of the weight variable. For instance, suppose I have 3 columns: RACE, AGE and WEIGHT. I would like, for example, the number of rows in my dataset where RACE = 1 and 20 <= AGE <= 35, corrected by the value of WEIGHT. So, if the value of WEIGHT for a row is 750, and the value of the column RACE is 'Black' and the value of the column AGE is between 20 and 35, 750 should be added to the count and not just 1.
I'm not sure this is very clear, but hopefully it's clear enough! I would be very grateful for your help, I have really no idea how to do that!
Best,
Philippe
[Solved] Conditional counting of cases with weights
[Solved] Conditional counting of cases with weights
Last edited by Hagar Delest on Thu Jun 22, 2017 8:52 am, edited 1 time in total.
Reason: tagged [Solved].
Reason: tagged [Solved].
OpenOffice 4.1.1 on MacOSX
Re: Conditional counting of cases with weights
If Race is in column A, Age is in column B and Weight is in C, then this should work for you
I wrote that as if the data are in rows 1 through 4.
Code: Select all
=SUMPRODUCT(A1:A4="Black";B1:B4>=20;B1:B4<=35;C1:C4)
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.