What Are Missing Values in SAS?
In SAS, missing values indicate an absence of values. Missing values can occur in both numeric and character variables:Numeric Missing Value: A dot (.).Character Missing Value: A blank space (' ' or "").
Types of Missing Values in SAS
1. Standard missing values
Standard missing values are represented in two ways:
For numeric variables: a single dot (.) and for character variables: blank or empty string ('' or "")
2. Special missing values (Numeric only)
There are also 27 special missing values in SAS (the special missing values are only useful in more advanced statistical modeling or imputation logic).
A special missing value would look like this: ._,and .A, .B, ..., .Z as a special missing value,they are distinguishable from just the standard dot missing .,and are also treated as missing.
How SAS Deals with Missing Values
In Numeric Calculations
An arithmetic operation involving a missing value will result in a missing value.
In Procedures
Most PROC steps will ignore missing values by default.
Example: PROC MEANS, PROC FREQ, PROC UNIVARIATE, etc.
Some procedures will allow you to include/exclude missing values intentionally with options like MISSING or NMISS.
Functions Related to Missing Values
Dealing with Missing Data
1. Finding You can find missing values through PROC PRINT, PROC FREQ, PROC MEANS, or your own code to identify missing values.
2. Filtering
3. Replacing/Imputing
You also can fill in the missing values by using conditional logic, means, medians, etc.
Missing Data in Sorting and Grouping SAS will place missing values first if it is sorted in ascending order. Missing values are a group in PROC SORT, PROC FREQ and PROC SQL.
Note:
Before conducting any statistical analysis, always check for missing data.
Use special missing values for every potential reason for a missing response (e.g., .A = refused, .B = not applicable).
When reading the data, you should include MISSOVER or DSD in INFILE statements in an attempt to deal with missing data properly while importing the data.
In SAS, missing values indicate an absence of values. Missing values can occur in both numeric and character variables:Numeric Missing Value: A dot (.).Character Missing Value: A blank space (' ' or "").
data sample;
input id age name $;
datalines;
1 . Shan
2 15 Jane
3 40
;
run;
- Row 1 has a missing numeric value for age.
- Row 3 has a missing character value for name.
Types of Missing Values in SAS
1. Standard missing values
Standard missing values are represented in two ways:
For numeric variables: a single dot (.) and for character variables: blank or empty string ('' or "")
2. Special missing values (Numeric only)
There are also 27 special missing values in SAS (the special missing values are only useful in more advanced statistical modeling or imputation logic).
A special missing value would look like this: ._,and .A, .B, ..., .Z as a special missing value,they are distinguishable from just the standard dot missing .,and are also treated as missing.
data intellectsage_missing;
x = .A;
y = ._;
run;
How SAS Deals with Missing Values
In Numeric Calculations
An arithmetic operation involving a missing value will result in a missing value.
data intellectsage_calc;
x = 1;
y = .;
z = x + y; /* z will be . (missing) */
run;
In Procedures
Most PROC steps will ignore missing values by default.
Example: PROC MEANS, PROC FREQ, PROC UNIVARIATE, etc.
Some procedures will allow you to include/exclude missing values intentionally with options like MISSING or NMISS.
Functions Related to Missing Values
Function | Description |
---|---|
MISSING() | Returns a 1 for missing value and 0 if otherwise |
NMISS() | Counts missing numeric |
CMISS() | Counts missing numeric or character |
IF var = . | Checks for missing numeric value |
IF var = '' | Checks for missing character value |
data intellectsage;
set sample;
if missing(name) then status = 'Missing name';
if cmiss(of id name) > 0 then flag = 'Some Missing';
run;
Dealing with Missing Data
1. Finding You can find missing values through PROC PRINT, PROC FREQ, PROC MEANS, or your own code to identify missing values.
2. Filtering
data intellectsage_no_missing;
set sample;
if age ne . and name ne '';
run;
3. Replacing/Imputing
You also can fill in the missing values by using conditional logic, means, medians, etc.
Or using PROC STDIZE:data intellectsage_fill;
set sample;
if age = . then age = 30; /* impute */
run;
proc stdize data=intellectsage reponly method=mean out=imputed;
var age;
run;
Missing Data in Sorting and Grouping SAS will place missing values first if it is sorted in ascending order. Missing values are a group in PROC SORT, PROC FREQ and PROC SQL.
Note:
Before conducting any statistical analysis, always check for missing data.
Use special missing values for every potential reason for a missing response (e.g., .A = refused, .B = not applicable).
When reading the data, you should include MISSOVER or DSD in INFILE statements in an attempt to deal with missing data properly while importing the data.