Hello!

I am conducting an honors thesis in sociology and need help with creating categories within a nominal variable. I have a nominal variable (called primarybc), which includes a list of about 20 birth control options (ex: abstinence, withdrawal, condoms, spermicide, IUD, patch, etc). I am trying to run analyses, however, I do not have enough observations in each option to give meaningful results. As such, I am trying to create classes, or categories, within primarybc to group some of the birth control options. For example, I want to create a subgroup called "barrier methods" which would include condoms and spermicides, and another subgroup called "hormonal self-administered methods" which would include pills and the patch.

How do I go about doing this? I have tried to do the following: gen classbc = 4 if primarybc == 7 | primarybc == 10 | primarybc == 13 |

No luck. Any thoughts?