Desktop productivity for business analysts and programmers

how to get unique columns in sas dataset

Reply
Contributor
Posts: 34

how to get unique columns in sas dataset

Hi,

I have a sas date set with 20 colums, say COL A,B,C... . i want to know the unive value of COL A and unique values of COL B and so on. I have a idea to read the same dataset 20 times and get rid of duplicates, but i think this is not an efficeint way of coding.

Could you please help me out of this problem
SAS Super FREQ
Posts: 8,820

Re: how to get unique columns in sas dataset

Hi:
I always find it useful to look at a concrete example of data when talking about duplicates. Consider this data:
[pre]
Obs a b c d e

1 A AA 1 4 3
2 A AA 1 4 3
3 A AA 2 8 3
4 A BB 4 5 6
5 A CC 7 8 3
6 B AA 1 8 3
7 B AA 1 8 3
8 B BB 1 4 3
9 B BB 4 5 6
10 B CC 5 6 7

[/pre]

Would you want to get RID of Observations 2 and 7 which are complete duplicates on EVERY column?

Or do you just want to find out what the unique values are? Something like this (produced by PROC FREQ):
[pre]
Number of Variable Levels

Variable Levels
--------------------
a 2
b 3
c 5
d 4
e 4


a Frequency
--------------
A 5
B 5


b Frequency
---------------
AA 5
BB 3
CC 2


c Frequency
--------------
1 5
2 1
4 2
5 1
7 1


d Frequency
--------------
4 3
5 2
6 1
8 4


e Frequency
--------------
3 6
6 2
7 1
9 1

[/pre]

It is also hard to make a recommendation without knowing what the outcome is supposed to be -- a report -- another data set???

Your best bet for help might be to contact Tech Support, because they can look at your data and figure out the best method in EG to accomplish your goal.

cynthia
Contributor
Posts: 34

Re: how to get unique columns in sas dataset

Hi, I need the PROC FREQ , Could you please send me the code
SAS Super FREQ
Posts: 8,820

Re: how to get unique columns in sas dataset

Hi,
Here's the code I used.
[pre]
proc freq data=testfile nlevels;
table a b c d e / nocum nopercent;
run;

[/pre]
cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 107 views
  • 0 likes
  • 2 in conversation