BookmarkSubscribeRSS Feed
DPraba79
Calcite | Level 5
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
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
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
DPraba79
Calcite | Level 5
Hi, I need the PROC FREQ , Could you please send me the code
Cynthia_sas
Diamond | Level 26
Hi,
Here's the code I used.
[pre]
proc freq data=testfile nlevels;
table a b c d e / nocum nopercent;
run;

[/pre]
cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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