What is the process for counting missing values in SAS and can you provide examples? 2

What is the process for counting missing values in SAS and can you provide examples?

The process for counting missing values in SAS involves using the COUNT function to calculate the number of missing values in a specific variable or column. This function will return the total count of missing values in the specified data set.

For example, if we have a dataset named “employees” with a variable named “salary”, we can use the COUNT function to determine the number of missing values in the “salary” column. The syntax for this would be:

COUNT(salary, “missing”);

This will return the total count of missing values in the “salary” column of the “employees” dataset.

Additionally, we can also use the PROC MEANS procedure to calculate the number of missing values in a dataset. This procedure will provide a summary of the data, including the number of missing values.

For instance, if we use the following code:

PROC MEANS DATA=employees;
VAR salary;
RUN;

The resulting output will include the number of missing values in the “salary” column of the “employees” dataset.

In summary, counting missing values in SAS involves using the COUNT function or the PROC MEANS procedure to determine the total count of missing values in a dataset or specific variable.

Count Missing Values in SAS (With Examples)


You can use the following methods to count the number of missing values in SAS:

Method 1: Count Missing Values for Numeric Variables

proc meansdata=my_data
    NMISS;
run;

Method 2: Count Missing values for Character Variables

proc sql; 
    select nmiss(char1) as char1_miss, nmiss(char2) as char2_miss
    from my_data;
quit;

The following examples show how to use each method in practice with the following dataset in SAS:

/*create dataset*/
data my_data;
    input team $ pos $ rebounds assists;
    datalines;
A G 10 8
B F 4 .
. F 7 10
D C . 14
E F . 10
F G 12 7
G C . 11
;
run;

/*view dataset*/
proc printdata=my_data;

Example 1: Count Missing Values for Numeric Variables

We can use the following code to count the number of missing values for each of the numeric variables in the dataset:

/*count missing values for each numeric variable*/
proc meansdata=my_data
    NMISS;
run;

From the output we can see:

  • There are 3 total missing values in the rebounds column.
  • There is 1 total missing value in the assists column.

Example 2: Count Missing Values for Character Variables

We can use the following code to count the number of missing values for each of the character variables in the dataset:

/*count missing for each character variable*/
proc sql; 
    select nmiss(team) as team_miss, nmiss(pos) as pos_miss
    from my_data; 
quit;

From the output we can see:

  • There is 1 missing value in the team column.
  • There are 0 missing values in the pos column.

Note: You can find the complete documentation for the NMISS function .

Additional Resources

The following tutorials explain how to perform other common tasks in SAS:

Cite this article

stats writer (2024). What is the process for counting missing values in SAS and can you provide examples?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/what-is-the-process-for-counting-missing-values-in-sas-and-can-you-provide-examples/

stats writer. "What is the process for counting missing values in SAS and can you provide examples?." PSYCHOLOGICAL SCALES, 29 Jun. 2024, https://scales.arabpsychology.com/stats/what-is-the-process-for-counting-missing-values-in-sas-and-can-you-provide-examples/.

stats writer. "What is the process for counting missing values in SAS and can you provide examples?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/what-is-the-process-for-counting-missing-values-in-sas-and-can-you-provide-examples/.

stats writer (2024) 'What is the process for counting missing values in SAS and can you provide examples?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/what-is-the-process-for-counting-missing-values-in-sas-and-can-you-provide-examples/.

[1] stats writer, "What is the process for counting missing values in SAS and can you provide examples?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. What is the process for counting missing values in SAS and can you provide examples?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top