Sample 25218: Using the MISSING Function from SAS Functions by Example
Using the MISSING function from SAS Functions by Example
By Ron Cody
Ever need to check for a missing value, but you're not sure if the variable is character or numeric? No problem when
you use the MISSING function. This function takes either character or numeric variables and it checks for the .A, .B, ._ numeric
missing values as well. For example:
DATA MISSING;
INPUT CHAR $ X Y;
IF MISSING(CHAR) THEN N_CHAR + 1;
IF MISSING(X) THEN N_X + 1;
IF MISSING(Y) THEN N_Y + 1;
DATALINES;
CODY 5 6
. . .
WHATLEY .A ._
LAST 10 20
;
PROC PRINT DATA=MISSING NOOBS;
TITLE "Listing of MISSING";
RUN;
A listing of MISSING, below, shows that the MISSING function works correctly with character and numeric values, including
all the alternative numeric missing values:
Listing of MISSING
CHAR X Y N_CHAR N_X N_Y
CODY 5 6 0 0 0
. . 1 1 1
WHATLEY A _ 1 2 2
LAST 10 20 1 2 2
About the Author
Ron Cody, Ed.D., is a professor and researcher at the Robert Wood Johnson Medical School in New Jersey as
well as a national instructor for SAS Institute Inc. A SAS user since 1977, Ron has the extensive knowledge and
innovative style that have made him a popular presenter at local, regional, and national SAS conferences.
He has authored or coauthored numerous books as well as countless articles in medical and scientific journals.
His books are available from the online bookstore.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Ever need to check for a missing value, but you're not sure if the variable is character or numeric? No problem when you use the MISSING function. This tip is from Ron Cody.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Internal Administration ==> BBU Non SAS Authors ==> Ron Cody SAS Reference ==> Functions ==> Character
|
| Date Modified: | 2006-01-11 03:03:01 |
| Date Created: | 2005-02-15 08:48:07 |
Operating System and Release Information
| SAS System | Base SAS | All | 8 TS M0 | n/a |
| SAS System | SAS/STAT | All | 8 TS M0 | n/a |