# Combination of codes

• Jun 19th 2012, 08:12 AM
cw2012
Combination of codes
Hi all,

I have been trying to figure a way of combining many codes per each individual subject ID. (each code represents a food consumed). What is the best programme to do this and how would this be done?

thanks
• Jun 20th 2012, 06:55 PM
BillSimpson
Re: Combination of codes
IF each food was either consumed or not and wasn't trying to count how many times it was consumed AND you didn't have too many different foods THEN you could create a list 1=banana, 2=apple, 4=potato, 8=pork, 16=etc, etc, etc. You just add up all the numbers and the total includes all the codes for all the foods. To extract the individual food codes you use remainder after division. What you are really doing is using one bit per code here.

You have not provided any information about what application this needs to be compatible with or how many codes you need to use. Some applications are more likely to accept long strings than they are huge numbers. If you need more than will fit in your number then you could use a similar encoding with ascii characters, except you start with a string of blanks. You are using the same one bit per code and just starting with blanks instead of zero because many applications might be less happy with a string containing nulls or control characters. Look at ASCII - Wikipedia, the free encyclopedia and try to see how you might be able to get six or seven bits in every character to represent six or seven foods and use a string long enough to have one bit for every food you need.

Lots of programs could do things like this, the choice depends on what you are familiar with, what other people you are working with are familiar with, whether you want to pay for this or must get it for free, how much time you want to spend learning how to use this, etc, etc, etc