BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
misaochan
Calcite | Level 5

What's the most efficient way to count the no. of distinct values of a particular variable in SAS EG? Google brings up the Data Exploration tool, but it seems to only work for datasets that aren't already in the SAS project. The dataset that I want to count is in the WORK library and is a product of a table join by the query builder.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If you only want EG then I suggest the summarize task twice. First time will get you the different counts of each level, the second will count the number of levels.

A different way is through a QUERY using count Distinct as a calculated variable.

View solution in original post

5 REPLIES 5
Reeza
Super User

Proc Freq nlevels option is the fastest that I know.

misaochan
Calcite | Level 5

Is that available as a task in EG? I meant a method specific to the UI in EG, if possible.

Reeza
Super User

If you only want EG then I suggest the summarize task twice. First time will get you the different counts of each level, the second will count the number of levels.

A different way is through a QUERY using count Distinct as a calculated variable.

ChrisHemedinger
Community Manager

There is a custom task that you can download.  It calculates the cardinality -- or number of distinct levels -- of each variable in your data set.

LINK: A custom task to check your data cardinality - The SAS Dummy

The UI looks like this:

http://blogs.sas.com/content/sasdummy/files/2013/10/cardtask.png

Chris

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
misaochan
Calcite | Level 5

Thank you all. Smiley Happy I did not want to install the custom task as sometimes I work on a machine that isn't mine. But COUNT DISTINCT works well.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 10703 views
  • 3 likes
  • 3 in conversation