How to find the unique sums in the values 1,2,4,8,16, 32 I apologize but I'm not sure what you would even call this problem. I have some data that provide a numeric code for race as follows: 
hispanic(1) + american_indian_or_alaska_native(2) + asian(4) + black_or_african_american(8) + native_hawaiian_or_other_pacific_islander(16) + white(32)
So for example, a 5 represents a person who identifies as Asian and Hispanic (4 + 1), and a 25 represents a person who identifies as Pacific Islander, Black, and Hispanic (16 + 8 + 1). 
I am trying to write a program that will retrieve what races are present from the given number. I figure there must be an equation that can determine the combination without detailing every unique combination, but I might be wrong! I tried to think about using modulo but I didn't get very far. 
Thanks, and if you have suggestions for tags, please comment as I'm not sure where this fits into mathematics. 
*edit Thanks everyone! This really helped me to think about the problem and generate an efficient solution. Answering my question didn't depend on using SAS but here is the SAS code I ended up using, which I think shows intuitively how to solve the problem: 
data want; 
    set have; 

/* convert decimal to 6-place binary */
    eth_bin = put(ethnicity, binary6.);  

/* if 1st digit is 1 then race is present, and so on*/ 
    if substr(eth_bin, 1, 1) = 1 then white = "Yes"; 
    if substr(eth_bin, 2, 1) = 1 then pacific_islander = "Yes"; 
    if substr(eth_bin, 3, 1) = 1 then black = "Yes"; 
    if substr(eth_bin, 4, 1) = 1 then asian = "Yes"; 
    if substr(eth_bin, 5, 1) = 1 then american_indian = "Yes"; 
    if substr(eth_bin, 6, 1) = 1 then hispanic = "Yes"; 
run; 


I don't know about SAS, but most programming languages have a bitwise AND operator. This is usually the word AND or the symbol & (the symbol && behaves slightly differently as it compares only TRUE and FALSE.) Thus there is no need to actually convert into a human readable binary.
Thus for a person identifying as american indian / white 100010 (34 decimal) assigned we get
a=34

Hispanic          a&1=0
American Indian   a&2=2
Asian             a&4=0
Black             a&8=0
Pacific Island    a&16=0
White             a&32=32

In many languages (C, Python, etc) a nonzero value will be interpreted as TRUE (truthy) and a zero value will be interpreted as FALSE (falsy).
In other languages, the behaviour may be different. For example in Ruby all values (including zero) are considered truthy, with the only exceptions being NIL (absence of data) and the FALSE itself. So we get slightly different code:
C:
if(a&4)puts("Asian");

Ruby:
puts "Asian" if a&4>0

