gen new variable: where are the categories?

#1
Hi everyone,

I am trying to create a new variable out of 4 variables. Ok, so basically in the raw data I have for variables for tool used to do some work. Each of these 4 variables has a code of 1.
I want to unify these four variables in one variable with 4 different categories, one for each of the tool.

This is the command that I type in but, dunno for what reasons, it does not work.

generate equip = .
replace equip = 1 if measur_tape == 1
replace equip = 2 if measur_pole == 1
replace equip = 3 if measur_sheet == 1
replace equip = a if calc ==1

So I assume I now have 1 var with 4 different categories. However, if I tab equip this I get only oneway table with one single category!
What about all the other 3 categories?? What I am missing ??

Thanks a lot !!!
 
#2
It would help to see an example of what your dataset looks like. Can you post a few lines? Also, do you mean to have both numerical and string values for equip?
 
#3
Is it possible that one observation can have the value of 1 for more than of the four listed variables, or are they exclusive? If an observation has 1 as measur_tape for example it can't have 1 for measur_pole.

Anyway, a better way of recoding your new variable is the recode command:

generate equip = .
recode equip (. =1) if measur_tape == 1
recode equip (.= 2) if measur_pole == 1
recode equip (.= 3) if measur_sheet == 1
recode equip (.= 4) if calc ==1

Also, when you tab it's useful to put missing on the end as an option... eg, 'tab equip, missing'.
 
#7
No, I am sorry mahkus: your command does not work. It gives me the same result that I got initially, that is I get only one way table with 1 category.
 
#9
Maybe it would help, butit would really help to see a few lines of your data. Cant you just post the variables we need to know about rather than the whole dataset? I would have thought mahkus' command would work, which makes me think theres something we can glean from seeing the data (like maybe your variables can take 1 in more than one instance or something)
 
#10
I have just now worked out what the problem was: basically I could not combine the different variables in a single one as multiple options were allowed.
So I do have to keep them separated.

Thanks a lot for your support!