BookmarkSubscribeRSS Feed

It would be great if there was a function similar to N() that counted the number of non-missing character values. Currently SAS has functions for counting missing character (CMISS) and numeric (NMISS) variables, and nonmissing numeric variables (N). So this seems like a logical hole to fill.

 

This article suggests development is investigating the possiblity but I wanted to emphasize my interest and hopefull others will as well.

 

http://support.sas.com/kb/46/235.html

4 Comments
ballardw
Super User

Proc FCMP and write your own.

 

Then it will do what you intend for given strings. I see things like "count characters except for numerals" , "except punctuation", "except special characters like @ # $ % ^ (etc)".

 

Encoding and unicode may be interesting to deal with as well....

ChrisBrooks
Ammonite | Level 13

As @ballardw says you could write your own with Proc FCMP however there is a problem with definition here (one I see that even the link has fallen into) and that is that strictly speaking character variables do not have missing values; they have empty strings - but how do you define an empty string? In the case of "" that is clearly empty but what about " " (single space) or any other white space character?

 

On a wider note I wouldn't say that just because we have Proc FCMP we should never ask for new inbuilt functions; An inbuilt function will always be faster than one built with Proc FCMP and while that won't be noticeable on a few thousand observations once your data moves into the millions and tens of millions of observations then it probably will be and I say that as someone who is a big fan of Proc FCMP Smiley Happy

 

In any case I understand that SAS 9.4 M5 becomes available next week so who knows, maybe CMISS will be in there!

Quentin
Super User

SAS has already decided the definition of a character missing value, in order to implement the missing() function can take character or numeric var as an argument.

 

Agree on your second point.  We should keep asking for new functions that are useful, even if they could be built with FCMP. 

barefootguru
Fluorite | Level 6

But Proc FCMP can’t have functions with a variable number of variables?