BookmarkSubscribeRSS Feed
Aexor
Lapis Lazuli | Level 10

Hi,

 

A sas library consists 10 datasets for e.g SASHELP lib, I want to find the variable having maximum number of unique values present in the SASHELP.

Please suggest.

 

Thanks!

 

 

3 REPLIES 3
Tom
Super User Tom
Super User

What have you tried?

Do you know how to find the variable you want for a single dataset?

Can you provide an example dataset and explain what you mean by maximum unique values?

 

I would recommend looking into the NLEVELS option on PROC FREQ.

mkeintz
PROC Star

Why?

 

And

  1. Do you want this just for numeric vars, character vars, or all vars?
  2. What about ID vars?  They are often unique values for each observation in a data set (like NAME in SASHELP.CLASS), so their cardinality is the same as the number of observations.  There would be no need to do frequencies to find the number of unique values.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Reeza
Super User

Let's break this down further:

  1. How to get the number of unique values in a single column, in a data set?
  2. How to do #1 for all of the data sets in a library? 
  3. Sort results from #2 and take records/data of interest?

Which steps do you need help with exactly? Please show what ever you've tried so far.

 


@Aexor wrote:

Hi,

 

A sas library consists 10 datasets for e.g SASHELP lib, I want to find the variable having maximum number of unique values present in the SASHELP.

Please suggest.

 

Thanks!

 

 


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 398 views
  • 2 likes
  • 4 in conversation