[Solved] Conditional counting of cases with weights
Posted: Thu Jun 22, 2017 12:32 am
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
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