BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

I have a dataset with approx 30 variables and I want to find out number of unique observation count for each variable

For ex:

data sample;
input empid sal name$;
cards;
101 1000 aaa
102 2000 bbb
103 2000 ccc
104 1000 ddd
run;


proc sql;
create table count as
select count(distinct(empid)) as count_eid,
count(distinct(sal)) as count_sal,
count(distinct(name)) as count_name
from sample;
quit;

the above query results to
4, 2 and 4

My problem is i want to automate the query rather than writing all the 30 variables in select query.

so, please reply me ASAP.
1 REPLY 1
data_null__
Jade | Level 19
Using PROC FREQ the syntax will be more concise.

[pre]
ods select Freq.NLevels;
ods output Freq.NLevels=Nlevels;
proc freq data=sample levels;
run;
ods select all;
Proc print;
run;
[/pre]
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 863 views
  • 0 likes
  • 2 in conversation