##### Personal tools
You are here: Home SAS SAS Missing Values

# SAS Missing Values

How work with SAS system missing values

1. Testing for missing values
2. Displaying and formatting missing values
3. Assigning missing values
4. Replacing missing values
5. Special missing

SAS stores 'missing' data depending on the variables data type: character or numeric. A 'missing' character value is represented as a blank (' ') or null (''). A 'missing' numeric value is represented as a single dot (.). Using SAS missing values rather than traditional '9' codes is a good idea. Not only does it avoid ambiguity (is YEAR=99 missing or equal to 1999?), but SAS will automatically exclude missing values from statistical calculations (although you can override this when appropiate).

Let's take a look at a dataset containing missing values. The response to the numeric variable Q2 is missing for ID=1. The value for the character variable GENDER is missing for ID=3.
      ID        Q1        Q2    GENDER--------------------------------------       1         4         .      M       2         2         2      F       3         2         1       4         1         2      F
SAS allows you to differentiate between values that are missing for different reasons. For example, in survey research a question may not be answered because the respondent refuses to answer or because they don't know the answer. SAS has a range of missing values to cover this case. These special missing values are for numerics only and are the letters of the alphabet preceded by the single dot .A thru .Z . In a PROC PRINT these values will appear as a single capital letter. In the following example, the response for the numeric variable Q3 is missing for all cases.
      ID        Q3------------------       1         A       2         D       3         .       4         D
Missing values are normally not included in any calculation in a PROC.
proc freq data = sasuser.miss;     tables gender q1-q3;     run;                           Cumulative  CumulativeQ1   Frequency   Percent   Frequency    Percent------------------------------------------------ 1          1      25.0           1       25.0 2          2      50.0           3       75.0 4          1      25.0           4      100.0                          Cumulative  CumulativeQ2   Frequency   Percent   Frequency    Percent------------------------------------------------ 1          1      33.3           1       33.3 2          2      66.7           3      100.0Frequency Missing = 1                          Cumulative  CumulativeQ3   Frequency   Percent   Frequency    Percent------------------------------------------------ 3          1     100.0           1      100.0Frequency Missing = 3
To include missing values in the calculations and/or be able to differentiate between any special missings in the dataset, use the /MISSING option on the TABLES statement in a PROC FREQ.
proc freq data = sasuser.miss;     tables gender q1-q3 /missing;     run;                           Cumulative  CumulativeQ1   Frequency   Percent   Frequency    Percent------------------------------------------------ 1          1      25.0           1       25.0 2          2      50.0           3       75.0 4          1      25.0           4      100.0                          Cumulative  CumulativeQ2   Frequency   Percent   Frequency    Percent------------------------------------------------ .          1      25.0           1       25.0 1          1      25.0           2       50.0 2          2      50.0           4      100.0
Q3   Frequency   Percent   Frequency    Percent------------------------------------------------ .          1      25.0           1       25.0 A          1      25.0           2       50.0 D          1      25.0           3       75.0 3          1      25.0           4      100.0
##### Document Actions

Copyright ©2013, The Pennsylvania State University | Privacy and Legal Statements
Contact the Help Site Administrator | Last modified Aug 13, 2008 | Weblion Partner