turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- PERCENT OF MISSING BY EACH GROUP VARIABLES

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-22-2017 11:01 PM

I'd like to get an idea of an extent of missing for each group of questions (variables) in my survey data. P1-P10, B1-B2 and G1-G5 are example of series of questions with missing (no response from study particpants). I believe there is lot more efficient way of doing this.

```
CP=NMISS(OF P01-P10)+N(OF P01-P10);
CB=NMISS(OF B1-B2)+ N(OF B1-B2);
CG=NMISS(OF G1-G5)+ N(OF G1-G5);
NP=NMISS(OF P01-P10);
NB=NMISS(OF B1-B2);
NG=NMISS(OF G1-G5);
```

P_MISSING_PERCENT=NP/CP*100;
B_MISSING_PERCENT=NB/CB*100;

G_MISSING_PERCENT=NG/CG*100;

Any suggestions please?

Thanks

Accepted Solutions

Solution

06-23-2017
09:06 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cruise

06-22-2017 11:12 PM

Well, I think you can do it in one, but besides that it's the same calculation. I don't think you're saving very much here though.

```
array p(*) p01-p10;
p_missing = nmiss(of p(*)) / dim(p);
```

All Replies

Solution

06-23-2017
09:06 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cruise

06-22-2017 11:12 PM

Well, I think you can do it in one, but besides that it's the same calculation. I don't think you're saving very much here though.

```
array p(*) p01-p10;
p_missing = nmiss(of p(*)) / dim(p);
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

06-23-2017 09:15 AM

`CP=NMISS(OF P01-P10)+N(OF P01-P10);`

Is there straightforward function to count the number of columns instead doing nmiss+n as shown in above code?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Cruise

06-23-2017 01:18 PM

If you are really asking how many variables are in the abbreviated variable list P01-P10, the answer will always be 10. The data step automatically creates the variables if they do not exist already in order to include them in the list.

If you are looking for an answer to the more general question, I don't know of a function to count the number of variables in a list. It is possible to define an array that contains the variable list, and then the DIM function will count the elements in the array:

array list(*) p01-p10; cp = dim(list);

I wouldn't argue that this simplifies anything, though.