# Missing values per case

#### iotapsi321

##### New Member
Hello! I am new to excel and have learned a lot from these messages boards and hope to keep the learning momentum going.

I have a large dataset with over 25k rows and hundreds of columns. I would like to delete rows (participants) who have over 50% missing values per variables. Each column reflects an item for a variable. For most variables, the sum of 4-5 consecutive columns (items) constitutes a variable. So in the case of a 4 item variable, I would like delete rows in where there is no value for 3 or more items. Any guidance you can provide would be a huge help.

#### DanteAmor

##### Well-known Member
You can put several examples covering all possible cases, there you indicate which are the rows that should be deleted.
Also comments, in which row the records begin and in which column the data to review begins

#### iotapsi321

##### New Member
Ok thanks. As an example, data begins on row 1 column 1. If a row is missing more than 2 values in columns A - D (variable 1), more than 3 values in columns E - J (variable 2), and more than 2 values in K- N (variable 3); then, I would like for that row to be deleted. Is this what you were looking for?

#### DanteAmor

##### Well-known Member
There are only 3 variables?
Are they always those columns?
Should the 3 conditions be met?

#### iotapsi321

##### New Member
There are more than these 3, perhaps too many to list. Just wanted to provide and example. Yes the data is always in those columns and the main condition to be met is that across each of the 3 variables there should be no more than 50% of missing values.

#### DanteAmor

##### Well-known Member
I'm sorry but I am not understanding.
You put three examples:

A - D (variable 1),
E - J (variable 2),
K- N (variable 3)

1. Are there more variables?

2. Is there a pattern to know how many columns are there per variable?

3. What is the condition?
a) If only one variable is met.
b) The 3 variables must be met.

It would also be great if you put 10 examples of the data you have on your sheet.

*If contains confidential information, you could replace it with generic data.

#### iotapsi321

##### New Member
I apologize for the lack of clarity. Below is a sample of generic data. I would like to delete participants 1,3, & 8 because they have over 50% of missing values on all 3 variables (so the condition is 50% across all 3 variables, which is why participant 6 retained and is not deleted). There is no consistent pattern for variables. Some variables have more items (columns) than others. Thanks again for all your help!

 Id# QMI1 QMI2 QMI3 QMI4 QMI5 QMI6 IAI1 IAI2 IAI3 IAI4 IAI5 IAI6 IAI7 IAI8 CT1 CT2 CT3 CT4 CT5 1 6 6 7 4 2 2 4 4 3 2 7 7 6 7 7 7 4 3 4 2 1 2 4 4 2 2 2 2 3 4 1 1 1 1 1 9 2 3 4 2 3 2 4 4 2 2 1 2 2 5 7 7 7 7 9 3 4 3 2 3 4 6 6 6 6 7 6 8 3 3 4 2 2 3 5 4 4 2 2 2 4 7 5 6 6 4 5 3 3 5 3 2 3 5 5 2 2 1 3 1 2 8 6 6 9 3 4 2 2 2 2 2 9 5 5 5 5 5 8 2 2 2 2 2 2 4 5 5 5 5 5 10 7 7 7 7 7 8 2 4 4 2 2 4 3 2 1 1 2 4

<colgroup><col><col span="19"></colgroup><tbody>
</tbody>

<tbody>
</tbody>

#### DanteAmor

##### Well-known Member
We need to find a pattern to determine the total columns per variable, I don't need to explain why?

QMI1 QMI2 QMI3 QMI4 QMI5 QMI6 (In this case the pattern could be QMI?)
IAI1 IAI2 IAI3 IAI4 IAI5 IAI6 IAI7 IAI8 (In this case the pattern could be IAI?)
CT1 CT2 CT3 CT4 CT5 (In this case the pattern could be CT?)

Those letters could be the pattern, that is, if the macro eliminates the numerical value, the letters remain, and that way we know how many columns are for the variable QMI, IAI and CT.

It makes sense to you.

#### iotapsi321

##### New Member
Oh yes that does. Here is the pattern of the ACTUAL variable names:
 RelAttend Religious Spiritual Dep Anx Combat Hmechng DA Dplyexp Stress Relation DplyRel Discrim Unit StressExp

<tbody>
</tbody>

#### DanteAmor

##### Well-known Member
Do you have that list of variables in some other sheet, in some column as a list?

Or You can create that list on some sheet, say "variable" sheet in Column A starting in cell A2.
With that I start the macro.