How to select count of distinct key based on indicator in another column?

105 views Asked by At

I have a table which is like this:

Geo_Key   Var1 Var2..Var50
123        1    0  .. 1
524        0    1  .. 1
323        1    1  .. 1

Where Var1-Var50 represents 50 columns having value 1/0.

I want to select count of distinct Geo_Key for each column(var1-var50), when its value is=1. So Results would be like:

Var1 50
Var2 60
....
...
Var50 10
1

There are 1 answers

1
Nirvik Banerjee On

Since your variables are binary( especially 0/1) in nature, you can also try summing each column up. The sum would give you the count of each variable with value = 1.

Or, you can try it using proc freq. Pleae check the following link

http://www2.sas.com/proceedings/sugi25/25/btu/25p069.pdf