Count Distinct Value of column in SAS

In this Tutorial we have explained on Count Distinct value of column in SAS. We will be getting count of distinct value of all the columns in SAS. We will be looking at an example

  • Count Distinct value of all the columns in SAS.
  • Count of distinct value of single column in SAS.

So we will be using EMP_DET Table in our example

 

Count of distinct value of all columns in SAS:

PROC FREQ along with nlevels and _all_ keywords are used to get count of distinct value of all the columns in SAS

/*count of distinct value of all column */ 

proc freq data=EMP_DET nlevels; 
tables _all_/noprint; 
run;

Column name and the distinct value of each column will be

 

Count distinct value of single column:

PROC FREQ along with nlevels keywords followed by column_name is used to get count of distinct value of all the columns in SAS

/*count of distinct value of single column */ 

proc freq data=EMP_DET nlevels;  
tables District/noprint;  
run;

Column name and the distinct value of column will be